dotansimha / dotansimha/graphql-code-generator
Error: Unable to merge GraphQL directive "abstractEntity"
- Dominant language
- TypeScript
- Stars
- 11.3k
- Forks
- 1.4k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 23
Description
**Describe the bug**
Codegen worked fine with "@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", and then accidently updated all packages to latest. Then got 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 (\node_modules\@graphql-tools\merge\index.js:162:15)
at mergeDirective (\node_modules\@graphql-tools\merge\index.js:167:9)
at mergeDirective (\node_modules\@graphql-tools\merge\index.js:167:9)
at mergeGraphQLNodes (\node_modules\@graphql-tools\merge\index.js:589:49)
at mergeGraphQLTypes (\node_modules\@graphql-tools\merge\index.js:658:25)
at Object.mergeTypeDefs (\node_modules\@graphql-tools\merge\index.js:605:22)
at makeExecutableSchema (\node_modules\@graphql-tools\schema\index.js:496:38)
at Object.mergeSchemas (\node_modules\@graphql-tools\schema\index.js:534:12)
at Object.codegen (\node_modules\@graphql-codegen\core\index.js:128:18)
at process (\node_modules\@graphql-codegen\cli\bin.js:1003:67)
at Array.map ()
Something went wrong
```
my codegen config
```
hooks:
afterAllFileWrite:
- prettier --write
require:
- ts-node/register
overwrite: true
schema: ./src/types/index.ts
definitions:
add: &top-comment
content: >
/**
* NOTE: THIS IS AN AUTO-GENERATED FILE. DO NOT MODIFY IT DIRECTLY.
*/
/* 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
```
Retried with rollbacking to different versions and fixed the error with older versions. And again updated one by one to latest and found the bug in graphql-codegen/cli starting from v2.
Working Sandbox (With prev versions) : https://codesandbox.io/s/cranky-bush-ojj8p
**To Reproduce**
Error Recreated in: https://codesandbox.io/s/relaxed-perlman-mdrwp
**Environment:**
- OS: Windows 11
- "@graphql-codegen/cli": "2.2.1"
- NodeJS: 14.18.0
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.