Fixed
Project:
GraphQL
Version:
8.x-4.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
27 Feb 2026 at 10:23 UTC
Updated:
29 Apr 2026 at 17:12 UTC
Jump to comment: Most recent
\Drupal\graphql\Plugin\GraphQL\Schema\SdlSchemaPluginBase::getSchema() does a cache get in \Drupal\graphql\Plugin\GraphQL\Schema\SdlSchemaPluginBase::getSchemaDocument() and does work and then does another cache get in \Drupal\graphql\Plugin\GraphQL\Schema\SdlSchemaPluginBase::getFullSchemaDocument() which makes all the previous work redundant. Let's check to see if the full cache exists
Remove ::getFullSchemaDocument() and put it's cache in the calling method above.
None
None
None
None
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #4
alexpottComment #5
kingdutchThe current form of caching actively breaks use-cases for things like directives (e.g graphql_oauth no longer works since that change was introduced). This is because the schema printer can only provide the SDL for the schema as a client would interpret it and can not preserve directives (since they may change server behaviour). There's a feature request in webonyx/graphql-php but it's blocked by the reference implementation (graphql-js) not actually supporting it.
With that in mind I want to make sure that #3572680: SdlSchemaPluginBase should cache AST instead of printing lands first, since it implements caching in a way that no longer actively breaks server-side behavior. That implementation is ready as of this week.
I would be curious to hear how that fares performance wise and if that's already an improvement. It does eliminate the full AST cache entirely, because the only way in the library to get that, while preserving things like directives, is to use
SchemaExtender::extend.I don't think we can cache the final
Schemainstance itself because it may contain closures. However, while writing this I can not directly point at any, so it may be worth experimenting with that route.One benefit of the implementation in #3572680: SdlSchemaPluginBase should cache AST instead of printing is that we're now caching ASTs which reduces the amount of times we print and parse SDLs.
Comment #6
alexpottI think this change is still good for the 4.x branch and I'll review #3572680: SdlSchemaPluginBase should cache AST instead of printing to make sure it is good for 5.x
Comment #8
alexpottEven if we have the cache this is the place where extension's resolvers are registered so we still need to do that.
On my site this change results in a massive performance improvement for a simple graphql query
Before
After
Comment #9
kingdutchThere was a request to merge and release this in 4.x even though we took a different route for 5.x. The 5.x equivalent of this is the AST caching, which also restores functionality for GraphQL Directives, but that requires breaking changes and is thus not suitable for the 4.x version.
This PR still provides a good performance improvement for people who can not yet move to 5.x. Thanks Alex!