graphql-code-generator icon indicating copy to clipboard operation
graphql-code-generator copied to clipboard

Got a duplicate identifier issue

Open MatteoGauthier opened this issue 3 years ago • 0 comments

Describe 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

  1. Run yarn codegen
  2. 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

MatteoGauthier avatar Jul 20 '22 21:07 MatteoGauthier