2.3 Generate Typescript Interfaces
1. Add dependencies
yarn add @graphql-codegen/cli @graphql-codegen/typescript @graphql-codegen/typescript-operations graphql --dev2. Make your API accessible
"graphql-codegen": "graphql-codegen",3. Create the codegen config file
name: GraphQL API
schema:
- [[API_URL]]/graphql/v1:
headers:
apiKey: "[[API_KEY]]"
documents: ./src/**/*.graphql.ts
generates:
./src/graphql-types.ts:
plugins:
- typescript
- typescript-operationsLast updated
Was this helpful?