graphql-tools: upgrade to graphql-tools@4.0.0 breaks custom schema directives
On upgrade to graphql-tools@4.0.0 from v3.1.1 causes compile time issues related to SchemaDirectiveVisitor
See reference build log https://travis-ci.org/ERS-HCL/nxplorerjs-microservice-starter/jobs/430812854
The date and auth directives are setup similar to what is explained in the documentation https://www.apollographql.com/docs/apollo-server/features/creating-directives.html
some snippets are given below
const schema = makeExecutableSchema({
typeDefs: myTypeDefs,
resolvers: resolvers,
schemaDirectives: {
date: FormattableDateDirective,
auth: AuthDirective
}
});
Property 'date' is incompatible with index signature.
Type 'typeof FormattableDateDirective' is not assignable to type 'typeof SchemaDirectiveVisitor'.
This was working fine till version 3.1.1 but now is breaking.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 18 (3 by maintainers)
@hwillson Nothing in the graphql changelog talks about directives needing to be declared in the schema.
Using https://gist.github.com/benjamn/de4b929ca88283925053a98d03f10ec5#file-schema-directives-using-directives-js as a base.
The problem seems to be that https://github.com/apollographql/graphql-tools/blob/b85137ba81c9bdc5667bced9cad9b1d226ea83fc/src/makeExecutableSchema.ts#L52
validates the directives (and throws an exception), but the directives from passed in schema directives wouldn’t be added until line 88 https://github.com/apollographql/graphql-tools/blob/b85137ba81c9bdc5667bced9cad9b1d226ea83fc/src/makeExecutableSchema.ts#L88
Exception stacktrace
@hwillson Can you say that by design graphql-tools
makeExecutableSchema
now(?) needs directives to be declared in the SDL? If so I don’t see there point in havinggetDirectiveDelcaration
on the SchemaDirectiveVisitor classes anyomore. Have I missed somethingOr is this a bug and the example should still work?