Git Product home page Git Product logo

grats's Introduction

Grats: Implementation-First GraphQL for TypeScript

Join our Discord!

Beta Software: Grats is largely stable and being used in production in multiple places. If you encounter any issues, don't hesitate to let us know.

The simplest way to build a GraphQL server in TypeScript

When you write your GraphQL server in TypeScript, your fields and resolvers are already annotated with type information. Grats leverages your existing type annotations to automatically extract an executable GraphQL schema from your generic TypeScript resolver code.

By making your TypeScript implementation the source of truth, you never have to worry about validating that your implementation matches your schema. Your implementation is your schema!

Read the blog post.

Example

Here's what it looks like to define a User type with a greeting field using Grats:

/** @gqlType */
class User {
  /** @gqlField */
  name: string;

  /** @gqlField */
  greet(args: { greeting: string }): string {
    return `${args.greeting}, ${this.name}`;
  }
}

After running npx grats, you'll find a schema.ts module that exports an executable schema, and a schema.graphql file contains your GraphQL schema definition:

type User {
  name: String
  greet(greeting: String!): String
}

That's just the beginning! To learn more, Read the docs: https://grats.capt.dev/

Contributing

See CONTRIBUTING.md in the repo root for details on how to make changes to this project.

Acknowledgements

License

Grats is MIT licensed.

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.