Graphql-tools: Typing errors in @graphql-tools/wrap 6.0.13

Created on 15 Jul 2020  Â·  5Comments  Â·  Source: ardatan/graphql-tools

  • Using graphql-tools 6.0.13 with typescript
  • graphql-tools 6.0.12 did not throw errors

Reproduction: https://codesandbox.io/s/stupefied-water-04jnz

package.json:

{
  "scripts": {
    "postinstall": "tsc"
  },
  "dependencies": {
    "graphql": "^15.3.0",
    "graphql-tools": "^6.0.13"
  },
  "devDependencies": {
    "typescript": "^3.9.6"
  }
}
λ yarn tsc
yarn run v1.22.4
node_modules/@graphql-tools/wrap/transforms/WrapFields.d.ts:20:5 - error TS2416: Property 'transformRequest' in type 'WrapFields' is not assignable to the same property in base type 'Transform'.
  Type '(originalRequest: Request, delegationContext: Record<string, any>, transformationContext: WrapFieldsTransformationContext) => 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 'Record<string, any>'.
        Type 'undefined' is not assignable to type 'Record<string, any>'.

20     transformRequest(originalRequest: Request, delegationContext: Record<string, any>, transformationContext: WrapFieldsTransformationContext): Request;
       ~~~~~~~~~~~~~~~~

node_modules/@graphql-tools/wrap/transforms/WrapFields.d.ts:21:5 - error TS2416: Property 'transformResult' in type 'WrapFields' is not assignable to the same property in base type 'Transform'.
  Type '(originalResult: ExecutionResult<Record<string, any>>, delegationContext: Record<string, any>, transformationContext: WrapFieldsTransformationContext) => ExecutionResult<...>' is not assignable to type 'ResultTransform'.
    Types of parameters 'delegationContext' and 'delegationContext' are incompatible.
      Type 'Record<string, any> | undefined' is not assignable to type 'Record<string, any>'.
        Type 'undefined' is not assignable to type 'Record<string, any>'.

21     transformResult(originalResult: ExecutionResult, delegationContext: Record<string, any>, transformationContext: WrapFieldsTransformationContext): ExecutionResult;
       ~~~~~~~~~~~~~~~

node_modules/@graphql-tools/wrap/transforms/WrapType.d.ts:7:5 - error TS2416: Property 'transformRequest' in type 'WrapType' is not assignable to the same property in base type 'Transform'.
  Type '(originalRequest: Request, delegationContext: Record<string, any>, transformationContext: Record<string, any>) => 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 'Record<string, any>'.
        Type 'undefined' is not assignable to type 'Record<string, any>'.

7     transformRequest(originalRequest: Request, delegationContext: Record<string, any>, transformationContext: Record<string, any>): Request;
      ~~~~~~~~~~~~~~~~

node_modules/@graphql-tools/wrap/transforms/WrapType.d.ts:8:5 - error TS2416: Property 'transformResult' in type 'WrapType' is not assignable to the same property in base type 'Transform'.
  Type '(originalResult: ExecutionResult<Record<string, any>>, delegationContext: Record<string, any>, transformationContext: Record<string, any>) => ExecutionResult<...>' is not assignable to type 'ResultTransform'.
    Types of parameters 'delegationContext' and 'delegationContext' are incompatible.
      Type 'Record<string, any> | undefined' is not assignable to type 'Record<string, any>'.
        Type 'undefined' is not assignable to type 'Record<string, any>'.

8     transformResult(originalResult: ExecutionResult, delegationContext: Record<string, any>, transformationContext: Record<string, any>): ExecutionResult;
      ~~~~~~~~~~~~~~~


Found 4 errors.

error Command failed with exit code 1.

my tsconfig.json:

{
  "compilerOptions": {
    /* Visit https://aka.ms/tsconfig.json to read more about this file */

    /* Basic Options */
    "module": "commonjs",
    "target": "es2019", // targeting node v12.9+
    "lib": ["es2020"],
    "outDir": "./build",
    "noEmit": true,

    /* Type-Checking Options */
    "strict": true,
    "noImplicitReturns": true,

    /* Module Resolution Options */
    "allowSyntheticDefaultImports": true,
    "esModuleInterop": true,

    /* Advanced Options */
    "forceConsistentCasingInFileNames": true
  },
  "include": [
    "src/"
  ]
}
bug

Most helpful comment

Released in 6.0.14.

All 5 comments

But #1614 was already released with v6.0.9 🤔
edit: Ah nvm, different files were modified in that PR. Now we need a similar fix in WrapFields

See #1783

https://codesandbox.io/s/laughing-raman-gccn1

Let me know how it works for you...

Released in 6.0.14.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

alfaproject picture alfaproject  Â·  4Comments

Adherentman picture Adherentman  Â·  4Comments

stubailo picture stubailo  Â·  3Comments

BassT picture BassT  Â·  3Comments

freiksenet picture freiksenet  Â·  4Comments