Home

Awesome

<p align="center"><img src="https://imgur.com/c6Y4tGw.png" width="150" /></p>

graphqlgen <!-- omit in toc -->

CircleCI npm version

Generate & scaffold type-safe resolvers based on your GraphQL Schema in TypeScript, Flow & Reason

Deprecation note

graphqlgen has been officially deprecated in favor of the The Guild's project GraphQL Code Generator. Learn more about the collaboration of Prisma and the Guild in this blog post.


About

Highlights

Motivation

Programming in type-safe environments can contribute toward great confidence in your code's integrity. graphqlgen aims to leverage the GraphQL type system to make your resolvers completely type-safe. This is important because resolvers are the heart of any graphql service and yet the hardest to statically type due to their dynaminism.

Supported languages

Others under discussion:

Getting started

Try out a project initializer

  1. Run initializer

    yarn create graphqlgen my-app # npm init graphqlgen my-app
    cd my-app
    yarn start # npm run start
    
  2. Edit ./my-app/src/schema.graphql to your heart's content.

  3. Generate types:

    yarn graphqlgen
    

Add to existing project

yarn add --dev graphqlgen # npm install --save-dev graphqlgen

Then you will have access to the cli (gg or graphqlgen):

yarn -s gg --help # npm run gg --help
Usage: graphqlgen or gg

Options:
  -i, --init     Initialize a graphqlgen.yml file
  -v, --version  Show version number                                   [boolean]
  -h, --help     Show help                                             [boolean]

gg depends on the presence of a graphqlgen.yml config located in the directory where gg is invoked. Here is an example:

language: typescript
schema: ./src/schema.graphql
context: ./src/context.ts:Context
output: ./src/generated/graphqlgen.ts
models:
  files:
    - ./src/generated/prisma-client/index.ts

Documentation

https://oss.prisma.io/graphqlgen

Addendum

Community

Join us at #graphqlgen in our Slack group and if you have more fleshed out ideas, bug reports etc. create a Github issue:

Project Status

graphqlgen is still in early stage development where breaking changes and tool design are a fluid matter. Feedback is deeply appreciated. You may feel comfortable giving it a try on production systems since there is no runtime aspect and hence quite safe to do so (save for a few optional default resolvers).

Prior Art

<p align="center"><a href="https://oss.prisma.io"><img src="https://imgur.com/IMU2ERq.png" alt="Prisma" height="170px"></a></p>