Skip to content

Conversation

@captbaritone
Copy link
Owner

@captbaritone captbaritone commented Dec 10, 2025

Basic idea here is that Grats can generate a special type which can be passed to Pothos such that you can use Pothos' add schema plugin to combine Grats and Pothos into a single schema while retaining type-safety.

Example usage:

import { getSchema} from "./schema"; // Generated by Grats
import { PothosUserSchemaTypes } from "./pothosTypes"; // Generated by Grats

const builder = new SchemaBuilder<PothosUserSchemaTypes>({
  plugins: [AddGraphQLPlugin],
  add: { schema: getSchema() },
  // Pothos + Grats' generated PothosUserSchemaTypes ensure this matches
  // the value in Grats config.
  defaultFieldNullability: true,
});

While Grats' approach is very attractive for most common cases, it's lack of access to runtime data can be limiting in terms of the abstractions that can be built. Conversely, Pothos has excellent support for many useful runtime abstractions and a large existing ecosystem. Maybe it's possible to have the best of both worlds, using the right tool for the job on a type-by-type basis?

Rather than trying to add a a runtime layer to Grats which would fight its design goals and requrie re-invent those abstractions, could we build a bridge to Pothos and let the two play together? This could also, in theory allow Pothos users to incrementally adopt Grats or just use it in a few places where it make sense while still relying on Pothos for useful plugins and other integrations.

TODO

The Pothos add schema plugin may not be quite sufficient for our needs here since it has type granularity. It's not possible to define a type in Grats and then extend it with a field defined with Pothos (though the API exists and is typesafe). It would in theory be possible to create a new plugin (or add a mode to the existing plugin) which merges types instead of clobbering them, but there would be some work involved in defining the semantics of how merging would work.

@netlify
Copy link

netlify bot commented Dec 10, 2025

Deploy Preview for grats failed. Why did it fail? →

Name Link
🔨 Latest commit 19d5f07
🔍 Latest deploy log https://app.netlify.com/projects/grats/deploys/6939d0d288a8110008927c3d

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants