Giter Club home page Giter Club logo

graphqlgen's Introduction

graphqlgen

CircleCI npm version

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

Features

  • 🚀 Schema-first: Based on your GraphQL schema (SDL) & model definitions
  • 🤝 Type-safe: Strong mapping between your GraphQL schema and resolvers, input arguments and models
  • ♻️ Codegen & scaffolding workflows: Minimal resolver boilerplate & automatically generated type definitions
  • 😍 Awesome DX: Auto-completion & Intellisense in VSCode, Webstorm, Atom, VIM & other editors
  • 💅 Ecosystem compatibility: Supports prettier and graphql-import out of the box

Documentation

You can find the docs for the graphqlgen CLI here.

Motivation

Programming in type-safe environments provides a lot of benefits and gives you confidence about your code. graphqlgen leverages the strongly typed GraphQL schema with the goal of making your backend type-safe while reducing the need to write boilerplate through code generation.

Supported languages:

Get started

Start from scratch

Bootstrap a GraphQL server based with a ready-made graphqlen setup:

npm init graphqlgen ./my-app

Then start the server:

cd my-app
yarn start

After updating the GraphQL schema in .my-app/src/schema.graphql, execute the graphqlgen CLI to update all resolvers:

graphqlgen

Add to existing project

Install

You can install the graphqlgen CLI with the following command:

npm install -g graphqlgen

Usage

Once installed, you can invoke the CLI as follows:

graphqlgen

The invocation of the command depends on a configuration file called graphqlgen.yml which must be located in the directory where graphqlgen is invoked. Here is an example:

language: typescript

schema: ./src/schema.graphql
context: ./src/types.ts:Context
models:
  files:
    - ./src/generated/prisma-client/index.ts

output: ./src/generated/graphqlgen.ts

resolver-scaffolding:
  output: ./src/generated/tmp-resolvers/
  layout: file-per-type

Learn more about the configuration in the docs.

Support

Note: Using graphqlgen in production

While graphqlgen is ready to be used in production, it's still in active development and there might be breaking changes before it hits 1.0. Most changes will just affect the configuration and generated code layout but not the behaviour of the code itself.

Credits

  • 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

Help & Community Slack Status

Join the #graphqlgen channel our Slack community if you run into issues or have questions. We love talking to you!

Prisma

graphqlgen's People

Contributors

arwalokhandwala avatar brikou avatar chakrihacker avatar dtalay avatar kuldar avatar manjula-dube avatar marktani avatar maticzav avatar nikolasburk avatar renovate-bot avatar schickling avatar sorenbs avatar timsuchanek avatar weakky avatar zachariahtimothy avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.