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.

Duplication identifier issue with codegen

See original GitHub issue

Describe the bug

I have a a query and a mutation inside ./src/graphql/queries. I’m generating to the folder ./src/graphql/generated/.

Somehow the codegen is generating all the typings twice, resulting in a lot of duplicate identifiers. My codegen config is below:

import type { CodegenConfig } from "@graphql-codegen/cli";

const config: CodegenConfig = {
  overwrite: true,
  debug: true,
  schema: "http://192.168.1.251:5050/api",
  documents: "src/graphql/queries/*.ts",
  ignoreNoDocuments: true,
  config: {
    withHooks: true,
    namingConvention: {
      enumValues: "keep",
    },
  },
  generates: {
    "./src/graphql/generated/": {
      preset: "client",
      config: {
        addUnderscoreToArgsType: true,
      },
      plugins: ["typescript", "typescript-operations", "typescript-urql"],
    },
    "./graphql.schema.json": {
      plugins: ["introspection"],
    },
  },
};

export default config;

Your Example Website or App

Not published

Steps to Reproduce the Bug or Issue

Have a query and a mutation in a folder, and run codegen on it. The types are generated TWICE in the same output file.

Expected behavior

The types should only be generated once for the schema.

Screenshots or Videos

No response

Platform

  • OS: Windows 10
  • NodeJS: v18.9.0
  • graphql version: ^16.6.0
  • @graphql-codegen/* version(s): 2.13.5

Codegen Config File

No response

Additional context

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:17

github_iconTop GitHub Comments

1reaction
chenninggcommented, Nov 3, 2022

@bfourgeaud Not much to be found in the documentation but from what I gather, the client preset is just like a collection of plugins to get you up and running fast. If you are specifying the plugins you want to use with their own individual options yourself, you are better off removing the client preset since it would be like specifying certain plugins twice (once from the preset and one more individually), which could explain the duplicates in the generation. I could be wrong, though.

1reaction
hl11jpcommented, Oct 12, 2022

I see. Thank you for your response!

Read more comments on GitHub >

github_iconTop Results From Across the Web

1.9.1 Duplicate identifiers when using typescirpt plugin #3046
Describe the bug. I just added a typescript plugin and start getting duplicate identifier errors all over the place.
Read more >
GraphQL Codegen duplicates RegisterDocument with ...
I'm Charly, from The Guild, working on GraphQL Code Generator. The preset: "client" is not meant to be used in combination with other ......
Read more >
Typescript codegen from graphql schema has types issues
Typescript codegen from graphql schema has types issues ... custom naming function - Duplicate identifier on Typescript type generation due ...
Read more >
typescript-react-query - GraphQL Code Generator
This plugin generates React-Query Hooks with TypeScript typings. It extends the basic TypeScript plugins: @graphql-codegen/typescript , @graphql ...
Read more >
lib/CodeGen/TailDuplication.cpp Source File - LLVM
1 //===- TailDuplication.cpp - Duplicate blocks into predecessors' tails ----===// ... 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception.
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