Minimal GraphQL tooling boilerplate with GraghQL Code Generator for Typescript that is easy to adapt and expand for any workflow.
Uses SpaceX GraphQL API 🚀 as an example endpoint. Replace
envvariables with your own endpoint and token if needed.
-
GraghQL Code Generator configuration
- Generates raw output for types and graphql operations for a more minimal approach
- Generates
TypedDocumentNodefor use with most GraphQL clients
-
VSCode plugin config for GraphQL
- GraphQL: Language Feature Support (
GraphQL.vscode-graphql)- config in
./graphql.config.js .envfile support in config
- config in
- GraphQL: Syntax Highlighting (
GraphQL.vscode-graphql-syntax)
- GraphQL: Language Feature Support (
-
Simple tesing environment to easily test generated graphql operations and types and expand to use GraphQL client libraries on top of
TypedDocumentNode
.env.example- environment variable example
.nvmrcnvmconfig
codegen.yml- Config for
@graphql-codegen/cliand related plugins - See codegen plugin related documentation in
codegen.yml
- Config for
graphql.config.js- Config for VSCode plugin: GraphQL: Language Feature Support
index.html- Easily test generated graphql code in browser environment with VSCode live server
tsconfig.json- TypeScript compiler options. Should also work with default config as created by
tsc --init.
- TypeScript compiler options. Should also work with default config as created by
.vscode/extensions.json- recommended extension needed by this boilerplate
src/index.ts- Inline GraphQL operation examples
- Used by
index.html- Easily test generated graphql operations and types
src/generated- contains all code generated by codegen per endpoint
src/gql-operations- GraphQL operations defined in
.graphqlfiles
- GraphQL operations defined in
src/utils/fakeTag.ts- exports
fake-tagthat is used to wrap GraphQL string operations- since this project doesn't use a bundler,
fake-tagis used here "inline"
- since this project doesn't use a bundler,
- exports
lib/- contains all files compiled by
tsc
- contains all files compiled by
# Copy env file and replace
cp .env.example .env
# Set correct node and npm version
nvm use
# Install dependencies
npm ci
# Start codegen in watch mode
npm run codegen:watch
# Start TypeScript compiler in watch mode
npm run tsc:watchInstall VSCode plugins:
-
GraphQL.vscode-graphql- GraphQL language features
- How to configure
- See open issues
- working version
0.7.5
-
GraphQL.vscode-graphql-syntax- GraphQL syntax highlighting
We are a hybrid marketing agency ready to set your business on fire by bringing together marketing communication and digital services in a unique way. We love technology and we hope this bit of code makes your day. If you're ever in need of marketing/design/development expertise why not consider us at nitro.fi 😎.