Skip to content

Feature Request: Add directiveIsRepeatable option to schema-ast plugin #10414

@1e16miin

Description

@1e16miin

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:

  1. When loading a schema from a remote URL, the CLI uses an introspection query that doesn't include the isRepeatable field
  2. The schema-ast plugin then calls printSchema() on the loaded schema
  3. Since the isRepeatable information wasn't included in the introspection, the repeatable 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

  1. Custom schema loader: Works but requires boilerplate code
  2. Two-step process: Download introspection manually, then use file - breaks the streamlined workflow
  3. 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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions