question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SyntaxError: Identifier 'builders' has already been declared (9:3)

See original GitHub issue

Describe the bug I’m trying to generate code from my ts files with graphql queries, but I get this error:

SyntaxError: Identifier 'builders' has already been declared (9:3)
        at Object._raise (/usr/src/app/client/node_modules/@graphql-tools/graphql-tag-pluck/node_modules/@babel/parser/lib/index.js:776:17)
        at Object.raiseWithData (/usr/src/app/client/node_modules/@graphql-tools/graphql-tag-pluck/node_modules/@babel/parser/lib/index.js:769:17)
        at Object.raise (/usr/src/app/client/node_modules/@graphql-tools/graphql-tag-pluck/node_modules/@babel/parser/lib/index.js:737:17)
        at TypeScriptScopeHandler.checkRedeclarationInScope (/usr/src/app/client/node_modules/@graphql-tools/graphql-tag-pluck/node_modules/@babel/parser/lib/index.js:1392:
12)
        at TypeScriptScopeHandler.declareName (/usr/src/app/client/node_modules/@graphql-tools/graphql-tag-pluck/node_modules/@babel/parser/lib/index.js:1358:12)
        at TypeScriptScopeHandler.declareName (/usr/src/app/client/node_modules/@graphql-tools/graphql-tag-pluck/node_modules/@babel/parser/lib/index.js:5081:11)
        at Object.checkLVal (/usr/src/app/client/node_modules/@graphql-tools/graphql-tag-pluck/node_modules/@babel/parser/lib/index.js:9742:24)
        at Object.checkLVal (/usr/src/app/client/node_modules/@graphql-tools/graphql-tag-pluck/node_modules/@babel/parser/lib/index.js:7298:15)
        at Object.parseVarId (/usr/src/app/client/node_modules/@graphql-tools/graphql-tag-pluck/node_modules/@babel/parser/lib/index.js:12531:10)
        at Object.parseVarId (/usr/src/app/client/node_modules/@graphql-tools/graphql-tag-pluck/node_modules/@babel/parser/lib/index.js:7126:11)

To Reproduce Steps to reproduce the behavior: I’ve tried to reproduce the error, but I got a new one. in codesandbox I get

TypeError: Cannot read property 'buildError' of undefined

https://codesandbox.io/s/zen-platform-dowef?file=/schema.gql

  1. My GraphQL operations:
import { gql } from '@apollo/client';

export const FULL_TASK = gql`
  fragment FullTask on Task {
    id
    title
    isCompleted
    isStarred
    atMyDay
    startDate
    startDateTime
    endDate
    endDateTime
    rrule
    missing
    recurringTaskId
    project {
      id
      title
      icon
      color
      backgroundColor
    }
  }
`;

import { gql } from '@apollo/client';

export const DELETE_TASK_MUTATION = gql`
  mutation deleteTask($taskId: String!) {
    deleteTask(taskId: $taskId) {
      ...FullTask
    }
  }
`;

  1. My codegen.yml config file:
overwrite: true
schema: "./schema.gql"
documents:
  - "./**/*.gql"
  - "./**/*.ts"
generates:
  generated.tsx:
    schema: "http://server:3000/graphql"
    plugins:
      - "typescript"
      - "typescript-operations"
      - "typescript-react-apollo"

Expected behavior It should generate code without any errors

Environment:

"@apollo/client": "3.3.11",
"@graphql-codegen/cli": "1.21.4",
"@graphql-codegen/introspection": "1.18.1",
"@graphql-codegen/typescript": "1.21.0",
"@graphql-codegen/typescript-operations": "1.17.14",
"@graphql-codegen/typescript-react-apollo": "2.2.1",

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:3
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

6reactions
apolloniancommented, Aug 3, 2021

@eden-lane Just ran into a similar issue with leftover/untracked declaration files conflicting with type gen. Try using the DEBUG mode to see where exactly the error is coming from. https://www.graphql-code-generator.com/docs/getting-started/codegen-config#debug-mode

1reaction
apolloniancommented, Aug 3, 2021

(Maybe just print a warning to the log with the invalid file path, and ignore that file?)

💯 This would be wonderful!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Uncaught SyntaxError: Identifier 'x' has already been declared
I am new to JavaScript and webdevelopment and am currently doing a course with Codecademy. I am creating a random message app that...
Read more >
Identifier "x" has already been declared" - Ep 11 - YouTube
JS Casts 11 - How to fix "Uncaught SyntaxError : Identifier "x" has already been declared " in JavaScript.
Read more >
Database Engine events and errors - SQL Server
Consult this MSSQL error code list to find explanations for error messages for SQL Server database engine events.
Read more >
PLS-00001 to PLS-01919 - Oracle Help Center
A string literal might have been mistakenly enclosed in double quotes instead of single quotes, in which case PL/SQL considers it a quoted...
Read more >
Build Tools Message Reference Manual - NXP
identifier name redeclared was declared as: typeA now declared as: typeB ... An attempt was made to redefine a macro that has already...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found