GraphQL is a query language for APIs, developed and open-sourced by Facebook. It allows clients to specify the required data structures, thus reducing unnecessary data transfers and improving the performance and maintainability of APIs.
GraphQL brings the following benefits:
GraphQL makes API development easy, but writing and maintaining GraphQL Schema and aligning it with TypeScript types and service logic is not a simple task.
In traditional GraphQL development, developers need to write the Schema manually, which leads to code redundancy and is difficult to maintain. With TypeScript, you also need to generate or manually edit type declarations. This means that the developer needs to write and maintain three sets of code at the same time: the GraphQL
schema, the resolver logic implementation, and the TypeScript
type declarations, which increases the burden on the developer.
In recent years, runtime type checking has become increasingly popular in the TypeScript community, with libraries such as Zod and Valibot allowing developers to write type declarations in JavaScript, providing robust type safety at development time and type safety at runtime.
More importantly, due to the runtime type checking nature of these libraries, the complete type information is already contained in their Schema. GQLoom
takes advantage of this by using the Schema written in Zod
and Valibot
as the source of facts, thus avoiding the tedious task of writing GraphQL
Schema manually, and providing more robust type safety. This eliminates the need to manually write GraphQL
Schema and provides more robust type safety.
In addition, many ORMs in the TypeScript ecosystem require table structures to be declared at development time, e.g., Prisma, Drizzle, MikroORM.
The goal of GQLoom
is to further reduce the burden on developers by directly using the table structures of these ORMs as Schema.
The design of GQLoom is inspired by tRPC, TypeGraphQL, Pothos.