grats
grats copied to clipboard
Specified directives from graphql-js are not included in schema
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
- Create a schema using grats and Apollo
- Attempt to run a query using
@skipor@includedirective
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.