1

I have graphql-codegen.yml file and src folder under project root path.

graphql-codegen.yml

schema: "https://swapi-graphql.netlify.app/.netlify/functions/index"
overwrite: true
documents: "src/**/*.graphql"
generates:
 src/generated/graphql-types.tsx:
 plugins:
 — "typescript"
 — "typescript-operations"
 — "typescript-react-apollo"

src/graphql/getAllPeople.graphql

query GetAllPeople($pageSize: Int) {
    allPeople(first: $pageSize) {
        people {
            name
            birthYear
            gender
            height
        }
    }
}

package.json

"scripts": {
        "graphql:codegen": "graphql-codegen — config graphql-codegen.yml"
    },
        "dependencies": {
        "@apollo/client": "^3.7.0",
        "@emotion/core": "^10.0.21",
        "@graphql-codegen/cli": "^2.16.2",
        "@graphql-codegen/fragment-matcher": "^3.3.3",
        "@graphql-codegen/typescript": "^2.8.6",
        "@graphql-codegen/typescript-operations": "^2.5.11",
        "@graphql-codegen/typescript-react-apollo": "^3.3.7"
    },

When I type command yarn graphql:codegen on terminal, it shows error:

yarn run v1.22.17
$ graphql-codegen — config graphql-codegen.yml
Unable to find Codegen config file! 

        Please make sure that you have a configuration file under the current directory!
      
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

What's wrong with the setting ?

Morton
  • 5,380
  • 18
  • 63
  • 118

0 Answers0