Skip to content

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

Open

Description

@queenvictoria

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}

Activity

  1. queenvictoria commented on Nov 22, 2023

    @queenvictoria
    Author

    I notice that on graphql@4.5 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
  2. Kingdutch commented on Nov 25, 2023

    @Kingdutch
    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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions