Grats
The cleanest way to build a TypeScript GraphQL server
No Duplication
Grats uses your existing TypeScript types to derive your GraphQL schema.
No Conflicts
Since your implementation is your schema, there's no need to validate that they match.
No Runtime
Grats extracts an executable graphql-js schema at build time. No Grats code is needed at runtime.
- Object Oriented
- Functional
/**
* A user in our kick-ass system!
* @gqlType */
class User {
/** @gqlField */
name: string;
/** @gqlField */
greet(greeting: string): string {
return `${greeting}, ${this.name}`;
}
}
Schema
"""A user in our kick-ass system!"""
type User {
greet(greeting: String!): String
name: String
}
/**
* A user in our kick-ass system!
* @gqlType */
type User = {
/** @gqlField */
name: string;
};
/** @gqlField */
export function greet(user: User, greeting: string): string {
return `${greeting}, ${user.name}`;
}
Schema
"""A user in our kick-ass system!"""
type User {
greet(greeting: String!): String
name: String
}