graphql-code-generator: Unable to find template plugin matching typescript-operations

Describe the bug New Angular Cli project Run npm init run standard install

To Reproduce Steps to reproduce the behavior:

  1. My GraphQL schema:
  • too big
  1. My GraphQL operations:
graphql-codegen init
graphql-codegen --config codegen.yml
  1. My codegen.yml config file:
overwrite: true
schema: "http://apollot:8972/samples/graphql/service"
documents: "src/**/*.graphql"
generates:
  src/generated/graphql.ts:
    plugins:
      - "typescript"
      - "typescript-operations"
      - "typescript-apollo-angular"
      - "typescript-graphql-files-modules"

Expected behavior Standard generate result

Environment:@graphql-codegen/typescript”: “1.3.0”, “@graphql-codegen/typescript-apollo-angular”: “1.3.0”, “@graphql-codegen/typescript-graphql-files-modules”: “1.3.0”, “@graphql-codegen/typescript-operations”: “1.3.0”,

Global cli package @graphql-codegen/cli 1.3.0

  • OS: Windows 10
  • @graphql-codegen/...:
  • NodeJS: 8.9.3

Additional context

image

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 17 (6 by maintainers)

Most upvoted comments

Hi @warrendodsworth ! Are you sure all dependencies are installed correctly? Did you ran yarn or npm install after adding the plugins to package.json? Can you please try to create a small reproduction in a repository?

Hi @warrendodsworth , I noticed the following in your repo:

  • Missing dependency @graphql-codegen/cli.
  • typescript-graphql-files-modules requires extensions d.ts so I recommend using it separately.
  • fragment-matcher is better used in a separate file.

You config should look like that:

generates:
  src/generated/graphql.ts:
    plugins:
      - "typescript"
      - "typescript-operations"
      - "typescript-apollo-angular"

  src/generated/modules.d.ts:
    plugins:
      - typescript-graphql-files-modules
      
  src/generated/fragment-matcher.json:
    plugins:
      - "fragment-matcher"

I couldn’t reproduce your issue with the reproduction repo. Tried with Node 10 and NPM (tried to install dependencies using yarn install and npm install) - it worked for me.

I encountered the same error and the reason was that I had both the new graphql-codegen namespaced packages, and the old ones (graphql-code-generator<-packageName>), resulting in a conflict:

  "devDependencies": {
    "@graphql-codegen/cli": "^1.8.1",
    "@graphql-codegen/typescript": "^1.8.1",
    "@graphql-codegen/typescript-document-nodes": "^1.8.1",
    "@graphql-codegen/typescript-graphql-files-modules": "^1.8.1",
    "@graphql-codegen/typescript-operations": "^1.8.1",
    "graphql-code-generator": "^0.18.2",
    "graphql-codegen-typescript-common": "0.18.2",
    "graphql-codegen-typescript-react-apollo": "0.18.2",
    "graphql-codegen-typescript-react-apollo-template": "^0.18.2"
  },

Removing the old ones solved it !

I also had this issue. Re-installing @graphql-codegen/typescript after i had installed the apollo plugin fixed it.

The issue for me is the init command added 3 packages which version is ‘0.0.0’, updated the fields solved it,

I had this problem, and it was caused by running wrong script. I ran yarn gql-gen instead of new yarn graphql-codegen

Hi @dotansimha, Thanks for getting back to me so quickly mate Yes, I did run npm i after adding the plugins using graphql-codegen init

I’ve created a small repo to reproduce the issue https://github.com/warrendodsworth/web-graphql-codegen-reproduce-bug