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 extracts your schema at build time from docblock hints. 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(args: { greeting: string }): string {
return `${args.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, args: { greeting: string }): string {
return `${args.greeting}, ${user.name}`;
}
Schema
"""A user in our kick-ass system!"""
type User {
greet(greeting: String!): String
name: String
}