Codegen 与 "@graphql-codegen/add": "^3.1.0", "@graphql-codegen/cli": "1.21.7", "@graphql-codegen/typescript": "1.23.0", “@graphql-codegen/typescript-resolvers”:“1.20.0”,“@graphql-codegen/typescript-mongodb”:“^1.19.5”,然后不小心将所有包更新到最新版本。然后得到TypeError:
yarn gen
√ Parse configuration
> Generate outputs
> Generate ./src/generated/graphql.ts
√ Load GraphQL schemas
√ Load GraphQL documents
× Generate
→ directive @abstractEntity(additionalFields: [AdditionalEntityFields], discriminatorField: String!) on INTERFACE
Found 1 error
✖ ./src/generated/graphql.ts
Error: Unable to merge GraphQL directive "abstractEntity".
Existing directive:
directive @abstractEntity(discriminatorField: String!, additionalFields: [AdditionalEntityFields]) on INTERFACE
Received directive:
directive @abstractEntity(additionalFields: [AdditionalEntityFields], discriminatorField: String!) on INTERFACE
at validateInputs (<path-to-project>\node_modules\@graphql-tools\merge\index.js:162:15)
at mergeDirective (<path-to-project>\node_modules\@graphql-tools\merge\index.js:167:9)
at mergeDirective (<path-to-project>\node_modules\@graphql-tools\merge\index.js:167:9)
at mergeGraphQLNodes (<path-to-project>\node_modules\@graphql-tools\merge\index.js:589:49)
at mergeGraphQLTypes (<path-to-project>\node_modules\@graphql-tools\merge\index.js:658:25)
at Object.mergeTypeDefs (<path-to-project>\node_modules\@graphql-tools\merge\index.js:605:22)
at makeExecutableSchema (<path-to-project>\node_modules\@graphql-tools\schema\index.js:496:38)
at Object.mergeSchemas (<path-to-project>\node_modules\@graphql-tools\schema\index.js:534:12)
at Object.codegen (<path-to-project>\node_modules\@graphql-codegen\core\index.js:128:18)
at process (<path-to-project>\node_modules\@graphql-codegen\cli\bin.js:1003:67)
at Array.map (<anonymous>)
Something went wrong
我的代码生成配置
hooks:
afterAllFileWrite:
- prettier --write
require:
- ts-node/register
overwrite: true
schema: ./src/types/index.ts
definitions:
add: &top-comment
content: >
/* eslint-disable */
generates:
./src/generated/graphql.ts:
plugins:
- add: *top-comment
- 'typescript'
- 'typescript-mongodb'
- 'typescript-resolvers'
config:
avoidOptionals: true
useIndexSignature: true
scalars:
DateTime: Date
EmailAddress: string
NonNegativeFloat: number
NonNegativeInt: number
我尝试回滚更新的软件包。但是现在错误并没有消失。
在以下位置重新创建错误:https ://codesandbox.io/s/relaxed-perlman-mdrwp