feat: add GQloom example: GraphQL + Zod + Prisma
This PR adds a GraphQL server example demonstrating a modern, type-safe stack with GQLoom, Prisma, GraphQL Yoga, and Zod.
The highlight of this example is GQLoom, a Code-First GraphQL schema library designed to enhance developer experience and productivity.
Key GQLoom Advantages Showcased:
-
Ergonomic API Design: GQLoom offers a semantic, code-first API that minimizes boilerplate and makes schema definition intuitive and enjoyable.
-
Single Source of Truth: It leverages runtime validation libraries like Zod as the single source of truth. Define your validation schema once, and GQLoom automatically derives both TypeScript types and the GraphQL schema, ensuring they are always in sync.
-
Automatic CRUD with ResolverFactory: This example heavily utilizes GQLoom's killer feature: the
PrismaResolverFactory. It automatically generates common queries (findUnique,findMany) and mutations (create,update,delete) directly from Prisma models, eliminating the need to write repetitive CRUD logic manually. -
End-to-End Type Safety: By integrating seamlessly with Prisma and Zod, GQLoom provides full type safety from the database to the API layer, catching errors at compile time.
Summary by CodeRabbit
-
New Features
- Added a complete GraphQL demo server with User and Post APIs, queries, and mutations (feed, drafts, signup, publish toggle, view count).
-
Documentation
- Added a comprehensive README with setup, migrations, seeding, and API usage examples.
-
Tests
- Added an automated test runner that boots services, applies migrations/seeds, waits for readiness, runs API collections, and cleans up.
-
Chores
- Added project configs: Node version pin, package/TS settings, and updated ignore patterns.
[!WARNING]
Rate limit exceeded
@xcfox has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 9 minutes and 42 seconds before requesting another review.
⌛ How to resolve this issue?
After the wait time has elapsed, a review can be triggered using the
@coderabbitai reviewcommand as a PR comment. Alternatively, push new commits to this PR.We recommend that you space out your commits to avoid hitting the rate limit.
🚦 How do rate limits work?
CodeRabbit enforces hourly rate limits for each developer per organization.
Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.
Please see our FAQ for further information.
📥 Commits
Reviewing files that changed from the base of the PR and between 9d3eda5b932735c3dcb00de875f7c0a57e6290c5 and 8e2afa1a6a322c779ee13bf78738b6128622323d.
đź“’ Files selected for processing (4)
.github/tests/orm/graphql-gqloom/run.sh(1 hunks)orm/graphql-gqloom/prisma/seed.ts(1 hunks)orm/graphql-gqloom/src/db.ts(1 hunks)orm/graphql-gqloom/src/resolvers/post.ts(1 hunks)
Walkthrough
Adds a new GraphQL example at orm/graphql-gqloom/: Prisma schema and seed, TypeScript resolvers and server using GQloom/Zod/Prisma, project config (package.json, tsconfig, .nvmrc, .gitignore), README, and a Bash test runner that boots Prisma Dev, runs migrations/seeds, launches the app, executes Newman tests, and cleans up.
Changes
| Cohort / File(s) | Summary |
|---|---|
Test Infrastructure \.github/tests/orm/graphql-gqloom/run.sh`` |
New Bash test runner: installs deps, starts Prisma Dev in background, waits for DATABASE_URL in logs, exports it, runs Prisma migrations and seeds, starts the Node app, waits for readiness, runs a Newman Postman collection (bail on error), and cleans up background processes on completion or failure. |
Project Configuration \orm/graphql-gqloom/.gitignore``, \orm/graphql-gqloom/.nvmrc``, \orm/graphql-gqloom/package.json``, \orm/graphql-gqloom/tsconfig.json`` |
Added ignore patterns, pinned Node version (lts/jod), project package metadata/scripts/dependencies, and a strict TypeScript configuration covering src and prisma. |
Database Layer \orm/graphql-gqloom/prisma/schema.prisma``, \orm/graphql-gqloom/prisma/seed.ts``, \orm/graphql-gqloom/src/db.ts`` |
New Prisma schema (Postgres datasource) with User and Post models and generators (prisma-client, prisma-gqloom); seed script creating users/posts using PrismaPg + withAccelerate; src/db.ts exports a configured prisma client instance. |
GraphQL Schema \orm/graphql-gqloom/schema.graphql`` |
Adds a comprehensive GraphQL schema: DateTime scalar, User and Post types, many filter/sort inputs and enums, queries (feed, draftsByUser, postById, users) and mutations (createDraft, deletePost, incrementPostViewCount, signupUser, togglePublishPost). |
Resolver Implementations \orm/graphql-gqloom/src/resolvers/post.ts``, \orm/graphql-gqloom/src/resolvers/user.ts`` |
New Prisma-backed resolvers: postResolver (queries and mutations including feed, draftsByUser, createDraft, togglePublishPost, incrementPostViewCount, deletePost) with Zod validation and field projection; userResolver with users, posts, and signupUser mutation supporting nested post creation. |
Server Setup \orm/graphql-gqloom/src/server.ts`` |
New GraphQL Yoga server wiring GQloom resolvers and Zod, mapping DateTime scalar, attempting to write the generated schema file, and listening on port 4000. |
Documentation \orm/graphql-gqloom/README.md`` |
Extensive README covering setup, migrations, seeding, server startup, API examples, schema evolution, and guidance for switching database providers. |
Sequence Diagram(s)
sequenceDiagram
participant Client
participant Server as GraphQL Server
participant Resolver as GQloom Resolver
participant Prisma as Prisma Client
participant DB as PostgreSQL
Client->>Server: GraphQL Query/Mutation
activate Server
Server->>Resolver: Route to resolver
activate Resolver
Resolver->>Resolver: Validate input (Zod)
Resolver->>Prisma: Execute DB operation
activate Prisma
Prisma->>DB: SQL (via PrismaPg + Accelerate)
activate DB
DB-->>Prisma: Result
deactivate DB
Prisma-->>Resolver: Data
deactivate Prisma
Resolver->>Resolver: Project selected fields
Resolver-->>Server: GraphQL response
deactivate Resolver
Server-->>Client: JSON response
deactivate Server
Estimated code review effort
🎯 3 (Moderate) | ⏱️ ~25 minutes
Possibly related PRs
- prisma/prisma-examples#8287: Adds a
dbmodule exporting a configured Prisma client using adapters/withAccelerate—closely related tosrc/db.ts. - prisma/prisma-examples#8276: Adds a near-identical Bash test-runner pattern that starts Prisma Dev, waits for
DATABASE_URL, runs migrations/seeds, launches the app, and runs tests—closely related to.github/tests/orm/graphql-gqloom/run.sh.
Pre-merge checks
âś… Passed checks (3 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title Check | ✅ Passed | The PR title "feat: add GQloom example: GraphQL + Zod + Prisma" directly and clearly summarizes the main change in the changeset. The title accurately reflects that the PR adds a new example project demonstrating the GQLoom library integrated with GraphQL, Zod, and Prisma—which aligns with all the files added (configuration, database setup, resolvers, server, documentation, and test runner). The title is concise, uses the conventional "feat:" prefix, avoids vague terminology, and provides specific technical context that would make the change immediately understandable to someone reviewing the commit history. |
| Docstring Coverage | âś… Passed | No functions found in the changes. Docstring coverage check skipped. |
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands and usage tips.