Graphql-tools: Cannot find module 'packages/delegate/src' or its corresponding type declarations

Created on 6 Jun 2020  Â·  7Comments  Â·  Source: ardatan/graphql-tools

After update to v6.0.8

> [email protected] build /Users/maxpain/Desktop/dev/fastcup/backend/api
> tsc

node_modules/@graphql-tools/wrap/transforms/FilterInputObjectFields.d.ts:3:35 - error TS2307: Cannot find module 'packages/delegate/src' or its corresponding type declarations.

3 import { DelegationContext } from 'packages/delegate/src';
                                    ~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@graphql-tools/wrap/transforms/RenameInputObjectFields.d.ts:3:35 - error TS2307: Cannot find module 'packages/delegate/src' or its corresponding type declarations.

3 import { DelegationContext } from 'packages/delegate/src';
                                    ~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@graphql-tools/wrap/transforms/TransformInputObjectFields.d.ts:4:35 - error TS2307: Cannot find module 'packages/delegate/src' or its corresponding type declarations.

4 import { DelegationContext } from 'packages/delegate/src';
                                    ~~~~~~~~~~~~~~~~~~~~~~~

Most helpful comment

Should be fixed in 6.0.9. Let us know if anything! Thanks so much!

All 7 comments

Hi @Maxpain177
Fixed on master;
You can try 6.0.9-alpha-db40e8a.0 until we release next version.

I have the same problem after update to 6.0.8.

If I update to 6.0.9-alpha-db40e8a.0:

node_modules/@graphql-tools/wrap/transforms/FilterInputObjectFields.d.ts:9:5 - error TS2416: Property 'transformRequest' in type 'FilterInputObjectFields' is not assignable to the same property in base type 'Transform'.
  Type '(originalRequest: Request, delegationContext: DelegationContext) => Request' is not assignable to type 'RequestTransform'.
    Types of parameters 'delegationContext' and 'delegationContext' are incompatible.
      Type 'Record<string, any> | undefined' is not assignable to type 'DelegationContext'.
        Type 'undefined' is not assignable to type 'DelegationContext'.

9     transformRequest(originalRequest: Request, delegationContext: DelegationContext): Request;
      ~~~~~~~~~~~~~~~~

node_modules/@graphql-tools/wrap/transforms/RenameInputObjectFields.d.ts:10:5 - error TS2416: Property 'transformRequest' in type 'RenameInputObjectFields' is not assignable to the same property in base type 'Transform'.
  Type '(originalRequest: Request, delegationContext: DelegationContext) => Request' is not assignable to type 'RequestTransform'.
    Types of parameters 'delegationContext' and 'delegationContext' are incompatible.
      Type 'Record<string, any> | undefined' is not assignable to type 'DelegationContext'.
        Type 'undefined' is not assignable to type 'DelegationContext'.

10     transformRequest(originalRequest: Request, delegationContext: DelegationContext): Request;
       ~~~~~~~~~~~~~~~~

node_modules/@graphql-tools/wrap/transforms/TransformInputObjectFields.d.ts:13:5 - error TS2416: Property 'transformRequest' in type 'TransformInputObjectFields' is not assignable to the same property in base type 'Transform'.
  Type '(originalRequest: Request, delegationContext: DelegationContext) => Request' is not assignable to type 'RequestTransform'.
    Types of parameters 'delegationContext' and 'delegationContext' are incompatible.
      Type 'Record<string, any> | undefined' is not assignable to type 'DelegationContext'.
        Type 'undefined' is not assignable to type 'DelegationContext'.

13     transformRequest(originalRequest: Request, delegationContext: DelegationContext): Request;

Could you share a reproduction repo or CodeSandbox?

Sure. https://github.com/oxilor/graphql-tools-issue-1605
To reproduce the typescript error, run yarn tsc

Classes FilterInputObjectFields, RenameInputObjectFields and TransformInputObjectFields implements the Transform interface from utils.

In this interface the second argument of the transformResult method is delegationContext?: Record<string, any>, but in the classes the second argument is delegationContext: DelegationContext.

May be in the Transform interface: https://github.com/ardatan/graphql-tools/blob/master/packages/utils/src/Interfaces.ts#L144

delegationContext?: Record<string, any>

should be

delegationContext: DelegationContext

DelegationContext from here https://github.com/ardatan/graphql-tools/blob/master/packages/delegate/src/types.ts#L20

strict setting in tsconfig pops this up.

Should be fixed in 6.0.9. Let us know if anything! Thanks so much!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MehrdadKhnzd picture MehrdadKhnzd  Â·  3Comments

Adherentman picture Adherentman  Â·  4Comments

dcworldwide picture dcworldwide  Â·  4Comments

tonyxiao picture tonyxiao  Â·  4Comments

avnersorek picture avnersorek  Â·  3Comments