Grats
Implementation-First GraphQL for TypeScript
What if building a GraphQL server were as simple as just writing functions?
No Duplication
Your TypeScript resolvers are already annotated with type information. Grats uses those existing types to determine your GraphQL schema.
No Conflicts
When your implementation is your schema, there's no need for clever TypeScript tricks to validate that your code and schema match.
No Library Code
Grats determines your schema at build time from docblock hints. There is no library code to import or invoke in your resolver code.
- Object Oriented
- Functional
/**
* A user in our kick-ass system!
* @gqlType */
class User {
/** @gqlField */
name: string;
/** @gqlField */
greet(args: { greeting: string }): string {
return `${args.greeting}, ${this.name}`;
}
}
Schema
"""A user in our kick-ass system!"""
type User {
name: String
greet(greeting: String!): String
}
/**
* A user in our kick-ass system!
* @gqlType */
type User = {
/** @gqlField */
name: string;
};
/** @gqlField */
export function greet(user: User, args: { greeting: string }): string {
return `${args.greeting}, ${user.name}`;
}
Schema
"""A user in our kick-ass system!"""
type User {
name: String
greet(greeting: String!): String
}