Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Argument #1 ($corsOptions) must be of type array, Drupal\\Core\\Http\\RequestStack given #1381

Open
queenvictoria opened this issue Nov 21, 2023 · 2 comments
Labels

Comments

@queenvictoria
Copy link

queenvictoria commented Nov 21, 2023

Recording this here. I'm getting an error with version 4.6 which causes my build to fail. I can't reproduce this on my local dev yet and haven't been able to dig in to it yet. I thought it was caused by an old configuration for a graphql site but have recreated this and it still fails.

I am using a custom schema written over a year ago so will try removing that to see if the issue persists.

Rolling back to 4.5 solves my issue.

TypeError: Drupal\\graphql\\Routing\\QueryRouteEnhancer::__construct(): Argument #1 ($corsOptions) must be of type array, Drupal\\Core\\Http\\RequestStack given, called in /opt/drupal/web/core/lib/Drupal/Component/DependencyInjection/Container.php on line 259 in /opt/drupal/web/modules/contrib/graphql/src/Routing/QueryRouteEnhancer.php on line 30 #0 /opt/drupal/web/core/lib/Drupal/Component/DependencyInjection/Container.php(259): Drupal\\graphql\\Routing\\QueryRouteEnhancer->__construct()
#1 /opt/drupal/web/core/lib/Drupal/Component/DependencyInjection/Container.php(177): Drupal\\Component\\DependencyInjection\\Container->createService()
#2 /opt/drupal/web/core/lib/Drupal/Component/DependencyInjection/Container.php(434): Drupal\\Component\\DependencyInjection\\Container->get()
#3 /opt/drupal/web/core/lib/Drupal/Component/DependencyInjection/Container.php(273): Drupal\\Component\\DependencyInjection\\Container->resolveServicesAndParameters()
#4 /opt/drupal/web/core/lib/Drupal/Component/DependencyInjection/Container.php(177): Drupal\\Component\\DependencyInjection\\Container->createService()
#5 /opt/drupal/web/core/lib/Drupal/Component/DependencyInjection/Container.php(434): Drupal\\Component\\DependencyInjection\\Container->get()
#6 /opt/drupal/web/core/lib/Drupal/Component/DependencyInjection/Container.php(237): Drupal\\Component\\DependencyInjection\\Container->resolveServicesAndParameters()
#7 /opt/drupal/web/core/lib/Drupal/Component/DependencyInjection/Container.php(177): Drupal\\Component\\DependencyInjection\\Container->createService()
#8 /opt/drupal/web/core/lib/Drupal/Component/DependencyInjection/Container.php(434): Drupal\\Component\\DependencyInjection\\Container->get()
#9 /opt/drupal/web/core/lib/Drupal/Component/DependencyInjection/Container.php(237): Drupal\\Component\\DependencyInjection\\Container->resolveServicesAndParameters()
#10 /opt/drupal/web/core/lib/Drupal/Component/DependencyInjection/Container.php(177): Drupal\\Component\\DependencyInjection\\Container->createService()
#11 /opt/drupal/web/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(136): Drupal\\Component\\DependencyInjection\\Container->get()
#12 /opt/drupal/vendor/symfony/http-kernel/HttpKernel.php(145): Drupal\\Component\\EventDispatcher\\ContainerAwareEventDispatcher->dispatch()
#13 /opt/drupal/vendor/symfony/http-kernel/HttpKernel.php(81): Symfony\\Component\\HttpKernel\\HttpKernel->handleRaw()
#14 /opt/drupal/web/modules/contrib/simple_oauth/src/HttpMiddleware/BasicAuthSwap.php(68): Symfony\\Component\\HttpKernel\\HttpKernel->handle()
#15 /opt/drupal/web/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Drupal\\simple_oauth\\HttpMiddleware\\BasicAuthSwap->handle()
#16 /opt/drupal/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\\Core\\StackMiddleware\\Session->handle()
#17 /opt/drupal/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(191): Drupal\\Core\\StackMiddleware\\KernelPreHandle->handle()
#18 /opt/drupal/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(128): Drupal\\page_cache\\StackMiddleware\\PageCache->fetch()
#19 /opt/drupal/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(82): Drupal\\page_cache\\StackMiddleware\\PageCache->lookup()
#20 /opt/drupal/vendor/asm89/stack-cors/src/Asm89/Stack/Cors.php(49): Drupal\\page_cache\\StackMiddleware\\PageCache->handle()
#21 /opt/drupal/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Asm89\\Stack\\Cors->handle()
#22 /opt/drupal/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\\Core\\StackMiddleware\\ReverseProxyMiddleware->handle()
#23 /opt/drupal/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\\Core\\StackMiddleware\
egotiationMiddleware->handle()
#24 /opt/drupal/web/core/lib/Drupal/Core/DrupalKernel.php(718): Stack\\StackedHttpKernel->handle()
#25 /opt/drupal/web/index.php(19): Drupal\\Core\\DrupalKernel->handle()
#26 {main}
@queenvictoria
Copy link
Author

I notice that on [email protected] though deployment succeeds that the edit page of the GraphQL server WSOD. This appears to be because the configuration relies on my plugin which was disabled. So it looks like the configuration doesn't require the module to be enabled. I don't know if that is something that could be done in the graphql--.yml.

dependencies:
  module:
    - graphql
    - custom-schema

@Kingdutch
Copy link
Contributor

So the root cause is likely that graphql.route_enhancer.query's service definition was changed which shouldn't be a problem but there are a few possible things in your environment that can cause this:

  1. You've altered the service and/or extended the class it depends on without making this change; or you're calling the service directly.
    2a. You've updated the code but Drupal has not had its container rebuild. This should happen automatically when you execute drush updb (though there are drush configurations in which this is a manual step.)
    2b. In case you get this before running drush updb, you may need to ensure your deployment_identifier in settings.php changes between deployments (by default this only changes with Drupal core versions, but it probably needs to change more often to also take contrib changes into account)

@Kingdutch Kingdutch added the 4.x label Nov 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants