GraphQL Codegen
Installation
$ yarn add --dev @ftw/graphql-codegen
Getting Started
Make sure your GraphQL server is running and then run the following in the root of your project (where http://localhost:3000/graphql is your GraphQL endpoint):
$ yarn run graphql-codegen http://localhost:3000/graphql
Using With GatsbyJS
Because GatsbyJS doesn't allow any JS files which don't export React components
in the "src/pages" directory, GraphQL Codegen allows outputting type
definitions to a single directory with the --flat
option:
$ yarn run graphql-codegen --flat -o src/__generated__ http://localhost:8000/___graphql