Experimental GraphQL code generator template for C# projects.
This template reads the introspection JSON of a GraphQL schema as an input. The user has to also mention the output folder where the file has to be written
The name of the output file can be defined in src/config.ts
For executing the template you can go through the steps below.
Open command prompt and go to working directory and create directory graphql-code-generator
.
cd graphql-code-generator
yarn add -D graphql @graphql-codegen/cli @graphql-codegen/introspection
Create a basic codegen.yml
configuration file, point to your schema like below
overwrite: true
schema: "schema path"
generates:
./graphql.schema.json:
plugins:
- 'introspection'
config:
minify: true
Then, run the graphql-codegen
command:
yarn graphql-codegen
This will generate introspection schema graphql.schema.json
. This will be used for generating types.
Go to working directory and clone graphql-codegen-csharp in the directory
yarn add -D [email protected] [email protected] [email protected]
npm install --save @types/[email protected]
cd graphql-codegen-csharp
npm install
Execute a yarn build
from the template folder so that a dist
folder is created in it.
cd ..
yarn gql-gen --schema ./graphql-code-generator/graphql.schema.json --template graphql-codegen-csharp --out ./
Other CLI Flag options are listed here.