0

I am using the graphql code generator with the typescript operations plugin to generate typescript types from my GraphQL schema. Everything was working fine until all of a sudden, when i run graphql-codegen --config codegen.yml the types generated were wrong.

The following image is from the file graphql.tsx where I keep all the generated types. image

Here you can also see that the graphql.tsx file has 145 problems. After a quick word search on that file I found out that the typescript utility type Pick is present 145 times. So the problem shown in the image, happens for every Pick type in the file. I think the Pick types are generated by the typescript operations plugin.

When i run graphql-codegen --config codegen.yml I gen no errors.

Everything on the GraphQL Playground at localhost:4000/graphql is woking fine.

My codegen.yml file:

overwrite: true
schema: "http://localhost:4000/graphql"
documents: "src/graphql/**/**/*.graphql"
generates:
  src/generated/graphql.tsx:
    plugins:
      - "typescript"
      - "typescript-operations"
      - "typescript-react-apollo"

What might be causing this problem.

Any help would be appreciated.

Panos JC
  • 1
  • 1
  • 3
  • Please make sure you're using the latest version of codegen and all of its plugins. – Daniel Rearden Dec 02 '20 at 13:21
  • I use the latest safe versions for codegen as well as its plugins. – Panos JC Dec 02 '20 at 13:38
  • 1
    I deleted `node_modules` and the `package_lock.json`, I deleted codegen and its plugins from `package.json`. I then run `npm install` and finally I installed codegen and the plugins separately. Now it work fine. Thanks for the quick response. – Panos JC Dec 02 '20 at 16:33

0 Answers0