#graphql #graphql-codegen
Вопрос:
Codegen отлично работал с «@graphql-codegen/add»: «^3.1.0», «@graphql-codegen/cli»: «1.21.7», «@graphql-codegen/typescript»: «1.23.0», «@graphql-codegen/typescript-распознаватели»: «1.20.0», «@graphql-codegen/typescript-mongodb»: «^1.19.5», а затем случайно обновил все пакеты до последней версии. Затем получил ошибку типа:
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-toolsmergeindex.js:162:15)
at mergeDirective (<path-to-project>node_modules@graphql-toolsmergeindex.js:167:9)
at mergeDirective (<path-to-project>node_modules@graphql-toolsmergeindex.js:167:9)
at mergeGraphQLNodes (<path-to-project>node_modules@graphql-toolsmergeindex.js:589:49)
at mergeGraphQLTypes (<path-to-project>node_modules@graphql-toolsmergeindex.js:658:25)
at Object.mergeTypeDefs (<path-to-project>node_modules@graphql-toolsmergeindex.js:605:22)
at makeExecutableSchema (<path-to-project>node_modules@graphql-toolsschemaindex.js:496:38)
at Object.mergeSchemas (<path-to-project>node_modules@graphql-toolsschemaindex.js:534:12)
at Object.codegen (<path-to-project>node_modules@graphql-codegencoreindex.js:128:18)
at process (<path-to-project>node_modules@graphql-codegenclibin.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: amp;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