@team-plain/graphql package provides a fully typed client for Plain’s GraphQL API. It is auto-generated from the GraphQL schema, which means every query and mutation available in the API is available in the SDK.
You can use any GraphQL client to interact with Plain’s API, but this SDK gives you type safety, automatic pagination, and structured error handling out of the box.
Installation
Setup
Queries
Queries are available underclient.query. Relations on returned models are lazy-loaded — accessing them triggers a separate API call automatically.
Mutations
Mutations are available underclient.mutation. Mutation errors are returned as typed data, not thrown as exceptions. This matches Plain’s API where all mutations return *Output types with an optional error field.
Pagination
Union types
GraphQL union and interface fields are exposed as discriminated unions of model classes. Each union member has a__typename property for type narrowing and supports the same lazy-loading as any other model.
Error handling
- Queries: network, auth (401), forbidden (403), and rate limit (429) errors throw typed exceptions (
AuthenticationError,ForbiddenError,RateLimitError,NetworkError,PlainGraphQLError). - Mutations: return the full
*Outputtype. Checkresult.errorfor a typedMutationErrorwithmessage,type,code, andfields[]. This is intentional — Plain’s API treats mutation errors as data.
Migrating from @team-plain/typescript-sdk
If you’re upgrading from the old @team-plain/typescript-sdk package, see the migration guide for a full breakdown of breaking changes.
Resources
- GraphQL schema — the full schema this SDK is generated from
- API explorer — browse and test queries interactively
- GitHub repository

