Grats

Implementation-First GraphQL for TypeScript
GitHub
312
Created 2 years ago, last commit 6 days ago
9 contributors
554 commits
Stars added on GitHub, month by month
12
1
2
3
4
5
6
7
8
9
10
11
2023
2024
Stars added on GitHub, per day, on average
Yesterday
=
Last week
+0.3
/day
Last month
+0.1
/day
Last 12 months
+0.5
/day
npmPackage on NPM
grats
0.0.30
Monthly downloads on NPM
12
1
2
3
4
5
6
7
8
9
10
11
2023
2024
README

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.