Got a duplicate identifier issue
See original GitHub issueDescribe the bug
The graphql codegen generate duplicate identifier. cf the codesandbox
export type NavigationItemsQueryVariables = Exact<{ [key: string]: never; }>;
export type NavigationItemsQuery = { __typename?: 'Query', homePage?: { __typename?: 'HomePage', id: string, navigation: Array<{ __typename?: 'NavigationItem', id: string, slug?: string | null, title?: string | null }> } | null };
export interface PossibleTypesResultData {
possibleTypes: {
[key: string]: string[]
}
}
const result: PossibleTypesResultData = {
"possibleTypes": {
"HomePageNavigationItems": [
"NavigationItem"
],
"Node": [
"Article",
"Asset",
"FieldOfWork",
"HomePage",
"NavigationItem",
"ScheduledOperation",
"ScheduledRelease",
"User"
],
"ScheduledOperationAffectedDocument": [
"Article",
"Asset",
"FieldOfWork",
"HomePage",
"NavigationItem"
]
}
};
export default result;
export type NavigationItemsQueryVariables = Exact<{ [key: string]: never; }>;
export type NavigationItemsQuery = { __typename?: 'Query', homePage?: { __typename?: 'HomePage', id: string, navigation: Array<{ __typename?: 'NavigationItem', id: string, slug?: string | null, title?: string | null }> } | null };
Your Example Website or App
https://stackblitz.com/edit/github-mvhfsr?file=graphql/generated/index.ts
Steps to Reproduce the Bug or Issue
- Run
yarn codegen
- Check the
graphql/generated/index.ts
file
Expected behavior
No duplicate identifier
Screenshots or Videos
No response
Platform
- OS: MacOS
- NodeJS: v16.13.2
graphql
16.5.0
"@graphql-codegen/cli": "2.9.1",
"@graphql-codegen/fragment-matcher": "3.3.0",
"@graphql-codegen/introspection": "2.2.0",
"@graphql-codegen/typescript": "2.7.2",
"@graphql-codegen/typescript-graphql-request": "^4.5.2",
"@graphql-codegen/typescript-operations": "2.5.2",
"@graphql-codegen/typescript-react-apollo": "3.3.2",
"@types/node": "^18.0.6",
"@types/react": "^18.0.15",
Codegen Config File
overwrite: true schema: “https://api-eu-central-1.hygraph.com/v2/cl335cxsw434p01z87rv1ba3t/master” documents: “graphql/queries/*.{ts,tsx,gql,graphql}” generates: ./graphql/generated/index.ts: plugins: - typescript - typescript-operations - fragment-matcher - typescript-operations - typescript-graphql-request config: namingConvention: enumValues: change-case-all#titleCase
Additional context
No response
Issue Analytics
- State:
- Created a year ago
- Reactions:5
- Comments:9
Top Results From Across the Web
Confusing "duplicate identifier" Typescript error message
When I ran npm start , I got a bunch of duplicate identifier errors. SOLUTION: From the project root folder run: rm -r...
Read more >How to fix the "duplicate identifier" error in TypeScript
If the answer to the previous question is yes, then you just found the reason to the “duplicate identifier” error. Remove the lines...
Read more >Fix TS2300 Duplicate identifier error in TypeScript with React
Have you updated your "react" and "@types/react" dependencies and now see error TS2300 and TS2717? Let me help you understand and fix these ......
Read more >How to fix: Duplicate identifier - Google Merchant Center Help
How to fix: Duplicate identifier ... There are multiple products in your product data that have the same product identifiers (for example, the...
Read more >Duplicate identifier errors. : r/typescript - Reddit
This is probably a rookie question but I have a folder that I use for TS practice, code snippets, and notes. What do...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@RomanBaiocco You get
duplicate
error becauseclient
preset is defined with plugins. You getvalidation
error because you don’t havetsx
extension as output in TS Config.@ardatan Thank you so much for the response! I’ll remove the client preset and see if that fixes it
Edit: It did! You’re amazing, thank you again!
For anyone who runs into this in the future, in
codegen.ts
I changedto