• This repository has been archived on 08/Dec/2021
  • Stars
    star
    818
  • Rank 55,733 (Top 2 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created over 6 years ago
  • Updated almost 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

⚙️ Generate type-safe resolvers based upon your GraphQL Schema

graphqlgen

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

  • Schema-first Design in SDL to derive ideal types
  • Type-safety Resolvers with precise signatures including parent, args and return type
  • DX Precise resolver types puts your editor intellisense to work
  • Ecosystem Interop codegen suitable for Yoga 1 or Apollo Server and supports prettier and graphql-import out of the box

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

  • TypeScript
  • Flow

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

  • gqlgen is the Golang equivalent of graphqlgen and served as a source of inspiration
  • graphql-code-generator is a similar tool based on templates support both frontend & backend

Prisma

More Repositories

1

graphql-prisma-typescript

🏡 GraphQL server reference implementation (Airbnb clone) in Typescript using Prisma & graphql-yoga
TypeScript
749
star
2

graphql-framework-experiment

Code-First Type-Safe GraphQL Framework
TypeScript
673
star
3

get-graphql-schema

Fetch and print the GraphQL schema from a GraphQL HTTP endpoint. (Can be used for Relay Modern.)
TypeScript
665
star
4

prisma-binding

GraphQL Binding for Prisma 1 (using GraphQL schema delegation)
TypeScript
476
star
5

yoga2

A lightweight 'Ruby on Rails'-like framework for GraphQL
TypeScript
347
star
6

python-graphql-client

Simple GraphQL client for Python 2.7+
Python
156
star
7

dripip

Opinionated CLI for continuous delivery of npm packages
TypeScript
100
star
8

konn

TypeScript
89
star
9

graphql-import-loader

Webpack loader for `graphql-import`
TypeScript
83
star
10

http-link-dataloader

📚📡 HTTP Apollo Link with batching & caching provided by dataloader.
TypeScript
77
star
11

bema

🐎 Delightful benchmarking for Node.js
TypeScript
73
star
12

graphql-framework-experiment-examples

Runnable examples to help you learn how to use Nexus.
TypeScript
64
star
13

nextjs-graphql-api-examples

Next.js example GraphQL API implementations
TypeScript
38
star
14

next-prisma-plugin

TypeScript
19
star
15

graphqlday.org

JavaScript
12
star
16

oss.prisma.io

Documentation content for oss.prisma.io (GraphQL Playground, GraphQL Yoga, GraphQL Config...)
10
star
17

vscode-next

TypeScript
6
star
18

graphql-config-extension-prisma

TypeScript
6
star
19

mockapie

TypeScript
1
star
20

renovate-config

Standard Renovate configurations for Labs team projects.
1
star
21

team

👩‍🔬👨‍🔬Past sprint demo recordings & more
1
star
22

prettier-config

Standard Prettier configuration for Labs team projects.
1
star