-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
Is your feature request related to a problem? Please describe.
I'm currently working with GraphQL schemas that use repeatable directives (like Apollo Federation's @key
directive), and when I generate SDL files using the schema-ast
plugin, the repeatable
keyword is missing from the output.
This seems to happen because:
- When loading a schema from a remote URL, the CLI uses an introspection query that doesn't include the
isRepeatable
field - The
schema-ast
plugin then callsprintSchema()
on the loaded schema - Since the
isRepeatable
information wasn't included in the introspection, therepeatable
keyword cannot be included in the generated SDL
I found that the introspection
plugin already has a directiveIsRepeatable
option (added in #4810), which works well for generating JSON introspection files. It would be great if the schema-ast
plugin could have similar functionality for SDL generation.
Describe the solution you'd like
Could you add a directiveIsRepeatable
option to the schema-ast
plugin configuration? This would allow users to include the repeatable
keyword in generated SDL files:
generates:
./schema.graphql:
plugins:
- schema-ast
config:
includeDirectives: true
includeIntrospectionTypes: true
directiveIsRepeatable: true # Include repeatable keyword for directives
This would ensure that repeatable directives are properly marked with the repeatable
keyword in the generated SDL, maintaining consistency with the original schema definition.
Describe alternatives you've considered
- Custom schema loader: Works but requires boilerplate code
- Two-step process: Download introspection manually, then use file - breaks the streamlined workflow
- Using introspection plugin: Only generates JSON, doesn't help with schema-ast plugin
Any additional important details?
This would make the schema loading behavior consistent with the introspection plugin options and allow full feature parity when working with modern GraphQL schemas that use repeatable directives (like Apollo Federation).
Related:
#4731 - Added introspection options to introspection plugin
#4810 - PR that implemented the above
The same getIntrospectionQuery options should be available for schema loading as they are for the introspection plugin.