Graphql: Error in compilation: TS2430: Interface 'GqlModuleOptions' incorrectly extends interface Pick<....>

Created on 7 Jan 2019  路  15Comments  路  Source: nestjs/graphql

I'm submitting a...


[ ] Regression 
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request

Current behavior


I try using npm run prestart:prod to compile code and get the error

node_modules/@nestjs/graphql/dist/interfaces/gql-module-options.interface.d.ts:7:18 - error TS2430: Interface 'GqlModuleOptions' incorrectly extends interface 'Pick<Config, "modules" | "context" | "cache" | "debug" | "plugins" | "schema" | "formatError" | "rootValue" | "validationRules" | "formatResponse" | "fieldResolver" | "tracing" | ... 12 more ... | "playground">'.
  Types of property 'schemaDirectives' are incompatible.
    Type '{ [name: string]: typeof SchemaDirectiveVisitor; }' is not assignable to type 'Record<string, typeof SchemaDirectiveVisitor>'.
      Index signatures are incompatible.
        Type 'typeof import("node_modules/@nestjs/graphql/node_modules/graphql-tools/dist/schemaVisitor").SchemaDirectiveVisitor' is not assignable to type 'typeof import("node_modules/graphql-tools/dist/schemaVisitor").SchemaDirectiveVisitor'.
          Property 'getDeclaredDirectives' is protected but type 'SchemaDirectiveVisitor' is not a class derived from 'SchemaDirectiveVisitor'.

7 export interface GqlModuleOptions extends Omit<Config, 'typeDefs'>, Partial<Pick<ServerRegistration, 'onHealthCheck' | 'disableHealthCheck' | 'path' | 'cors' | 'bodyParserConfig'>> {

Environment


"@nestjs/common": "^5.1.0"
"@nestjs/core": "^5.1.0"
"@nestjs/graphql": "^5.4.0"
"graphql": "^14.0.2"
"graphql-tools": "^4.0.3"
"graphql-type-json": "^0.2.1"
"typescript": "^3.0.1"

tsconfig.json


{
  "compilerOptions": {
    "module": "commonjs",
    "lib": ["esnext", "dom"],
    "declaration": true,
    "noImplicitAny": false,
    "removeComments": true,
    "noLib": false,
    "allowSyntheticDefaultImports": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "target": "es6",
    "sourceMap": true,
    "outDir": "./dist",
    "baseUrl": "./src"
  },
  "include": ["src/**/*"],
  "exclude": ["node_modules", "**/*.spec.ts"]
}

For Tooling issues:


- Node version: v10.14.2  
- Platform: Mac 

Most helpful comment

the quick fix is:
`
// node_modules\@nestjs\graphql\dist\interfaces\gql-module-options.interface.d.ts

import { Type } from '@nestjs/common';
import { ModuleMetadata } from '@nestjs/common/interfaces';
import { Config, IResolverValidationOptions, ServerRegistration, SchemaDirectiveVisitor } from 'apollo-server-express';
import { IDirectiveResolvers, } from 'graphql-tools';
`
import the SchemaDirectiveVisitor from apollo-server-express instead of graphql-tools
ref#this

All 15 comments

Have this problem in linux锛宐ut windows nothing.

Having the same problem on Windows.

Any idea?

same problem here

the quick fix is:
`
// node_modules\@nestjs\graphql\dist\interfaces\gql-module-options.interface.d.ts

import { Type } from '@nestjs/common';
import { ModuleMetadata } from '@nestjs/common/interfaces';
import { Config, IResolverValidationOptions, ServerRegistration, SchemaDirectiveVisitor } from 'apollo-server-express';
import { IDirectiveResolvers, } from 'graphql-tools';
`
import the SchemaDirectiveVisitor from apollo-server-express instead of graphql-tools
ref#this

same issue, Mac

the issue seems to only happen in version 5.5.0 you can set these to 5.4.0:

"@nestjs/common": "5.4.0"
"@nestjs/core": "5.4.0"
"@nestjs/graphql": "5.4.0"

no ^

this compiles for me. the issue that @workoo refers to is the true culprit and this package should look to upgrade from graphql-tools: 3.1.1 to 4+

@sgraham785 It works. Thanks. But I this issue should be kept opened.

Should be fixed in 5.5.1

I still get this error in 5.5.1

No fix, why should I close it?

It should not be closed.

I have just published 5.5.2 Could you check now?

Already fixed

It's fixed. So, this bug can be closed.

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings