apollo-validation-directives icon indicating copy to clipboard operation
apollo-validation-directives copied to clipboard

type issue

Open nicolasburtey opened this issue 4 years ago • 2 comments

trying to run the Value validation example.

I'm being returned this issue by typescript :

error TS2322: Type 'typeof ConcreteValidateDirectiveVisitor' is not assignable to type 'typeof SchemaDirectiveVisitor'.
  Types of property 'visitSchemaDirectives' are incompatible.
    Type '(schema: GraphQLSchema, directiveVisitors: { [directiveName: string]: typeof SchemaDirectiveVisitor; }, context?: { [key: string]: any; } | undefined) => { [directiveName: string]: SchemaDirectiveVisitor[]; }' is not assignable to type '(schema: GraphQLSchema, directiveVisitors: Record<string, typeof SchemaDirectiveVisitor>, context?: Record<string, any> | undefined, pathToDirectivesInExtensions?: string[] | undefined) => Record<...>'.
      Types of parameters 'directiveVisitors' and 'directiveVisitors' are incompatible.
        Type 'Record<string, typeof SchemaDirectiveVisitor>' is not assignable to type '{ [directiveName: string]: typeof SchemaDirectiveVisitor; }'.
          Index signatures are incompatible.
            Type 'typeof import("node_modules/@graphql-tools/utils/SchemaDirectiveVisitor").SchemaDirectiveVisitor' is not assignable to type 'typeof import("node_modules/apollo-server-core/node_modules/graphql-tools/dist/schemaVisitor").SchemaDirectiveVisitor'.
              The types returned by 'getDirectiveDeclaration(...)' are incompatible between these types.
                Type 'GraphQLDirective | null | undefined' is not assignable to type 'GraphQLDirective'.
                  Type 'undefined' is not assignable to type 'GraphQLDirective'.

adding // @ts-ignore before schemaDirectives: { range }, is silencing the issue

nicolasburtey avatar May 10 '21 15:05 nicolasburtey

The type of SchemaDirectiveVisitor from graphql-tools changed from v5 onwards. This lib will work with v4 of graphql-tools.

smbkr avatar May 21 '21 19:05 smbkr

this will be fixed once we update to apollo v3 and newer graphql-tools, likely with #56

barbieri avatar Jul 20 '22 23:07 barbieri