graphql-resolvers icon indicating copy to clipboard operation
graphql-resolvers copied to clipboard

Typescript: Types of parameters 'info' and 'info' are incompatible.

Open dan-lutd opened this issue 3 years ago • 0 comments

The full error is:

 Type 'IFieldResolver<any, any, any, any>' is not assignable to type 'Resolver<Maybe<any[]>, {}, any, {}> | undefined'.
    Type 'IFieldResolver<any, any, any, any>' is not assignable to type 'ResolverFn<Maybe<any[]>, {}, any, {}>'.
    Types of parameters 'info' and 'info' are incompatible.

    Type 'GraphQLResolveInfo' is not assignable to type 'GraphQLResolveInfo & { mergeInfo?: MergeInfo | undefined;}'.
        Type 'import(" ./node_modules/graphql/type/definition").GraphQLResolveInfo'  assignable to e 'import(" ./node_modules/@types/graphql-resolvers/node_modules/graphql/type/definition").GraphQLResolveInfo'.
        Types of property 'returnType' are incompatible.
            Type 'import(" ./node_modules/graphql/type/definition").GraphQLOutputType' is not assignable to type 'import(" ./node_modules/@types/graphql-resolvers/node_modules/graphql/type/definition").GraphQLOutputType'.

            Type 'GraphQLScalarType' is not assignable to type 'GraphQLOutputType'.
                Type 'GraphQLScalarType' is missing the following properties from type 'GraphQLEnumType': getValues, getValue`

but I thing the first issue is: Types of parameters 'info' and 'info' are incompatible.

It looks like the Types for info in index.d.ts from the types for your library: https://www.npmjs.com/package/@types/graphql-resolvers Someone must have published them :-) thanks @rwieruch

I tried a simple change to the index.d.ts export type IFieldResolver<TSource, TContext, TArgs = Record<string, any>, TReturn = any> = ( source: TSource, args: TArgs, context: TContext, info: GraphQLResolveInfo & { mergeInfo?: MergeInfo | undefined } | any, ) => TReturn; Luis Felipe Zaguini by adding the | any on the info type I'm hoping someone who is versatile with this repo and types will be able to help.

dan-lutd avatar Jul 27 '21 22:07 dan-lutd