Codapult includes an optional graphql-yoga server for teams that prefer GraphQL over REST or tRPC. It is an independent module and can be removed without affecting other API layers.
Endpoint
The endpoint is /api/graphql. Send queries and mutations with POST and a
JSON body. GET is available only for the development GraphiQL playground;
the production route returns 404 for GET.
In development, graphql-yoga serves a built-in GraphiQL playground at the same URL when accessed from a browser.
When to Use GraphQL vs tRPC
| Use case | Recommended |
|---|---|
| Internal frontend ↔ backend communication | tRPC |
| Public API for third-party consumers | GraphQL |
| Mobile app with varied data requirements | GraphQL |
| Dashboard with full-stack TypeScript | tRPC |
| Need introspection/schema discovery | GraphQL |
Both layers can be used in the same application. Their request limits are configured independently: GraphQL allows 60 requests per minute per IP, while tRPC allows 200. GraphQL limits query depth and disables schema introspection in production.
Authentication
The endpoint uses the current application session. Public fields such as
plans can be queried without signing in; user-specific fields and mutations
require a valid session and return a GraphQL error otherwise. For example:
{
"query": "query { plans { id name } }"
}
Send it as the POST body to /api/graphql. Check the resolver access policy
for each field before exposing additional data; authentication on the route
does not automatically make every field private or every user-data query safe.
Removal
GraphQL is a separately mapped optional module. Use the setup wizard:
npx @codapult/cli setup
The setup wizard identifies the module's removal changes. Review its proposed diff and run the project's typecheck and tests afterward.