grats icon indicating copy to clipboard operation
grats copied to clipboard

Specified directives from graphql-js are not included in schema

Open felamaslen opened this issue 3 months ago • 0 comments

When creating a schema in graphql-js, certain directives are included by default, including but not limited to:

  • @skip
  • @include

These directives are not created in the grats generated schema. The full list is specified in the specifiedDirectives export from graphql.

Steps to reproduce

  1. Create a schema using grats and Apollo
  2. Attempt to run a query using @skip or @include directive

Expected behaviour: the query works as expected Actual behaviour: the query throws a validation error on missing directive usage

Cause

You can see in buildASTSchema that graphql-js is adding the specifiedDirectives:

const directives = [
    ...config.directives,
    // If specified directives were not explicitly declared, add them.
    ...specifiedDirectives.filter((stdDirective) =>
      config.directives.every(
        (directive) => directive.name !== stdDirective.name,
      ),
    ),
  ];

I believe these directives are missing in grats schemas due to the way grats intantiates the schema.

felamaslen avatar Oct 20 '25 12:10 felamaslen