Generate a GraphQL schema for a domain, including types, queries, mutations, subscriptions, directives, and resolvers. Do NOT use for REST API design, OpenAPI spec generation, or GraphQL client code generation.
Generate complete, best-practice GraphQL schemas including SDL and resolver outlines.
| Variable | Type | Req | Description |
|---|---|---|---|
tech_stack | string | Yes | e.g., "Node.js + Apollo Server" |
domain_description | string | Yes | Entities, relations, and business rules |
operations | string | Yes | Required queries, mutations, subscriptions |
| Case | Strategy |
|---|---|
| Circular refs | Use lazy types; enforce resolver depth limits. |
| Large results | Enforce first arguments with maximum caps. |
| Field-level Auth | Apply @auth directives; specify field-level resolver placement. |
flowchart TD
A([Start: GraphQL Schema Generation]) --> B{Schema source?}
B -- Domain model --> C[Map entities → GraphQL types]
B -- REST API --> D[Convert endpoints → queries/mutations]
B -- Database schema --> E[Introspect tables → types + resolvers]
C & D & E --> F[Define scalar types: ID, String, Int, DateTime, custom]
F --> G[Model relationships: one-to-one, one-to-many, many-to-many]
G --> H{Nullable vs non-null?}
H --> I[Apply ! where field is always present]
I --> J[Define Query type: list, single, filtered, paginated]
J --> K{Mutations needed?}
K -- Yes --> L[Define Mutation type: create, update, delete, batch]
K -- No --> M
L --> M{Subscriptions needed?}
M -- Yes --> N[Define Subscription type for real-time events]
M -- No --> O
N & O --> P[Define input types for mutations]
P --> Q{Auth/access control?}
Q -- Yes --> R[Add directives: @auth, @deprecated, @skip, custom]
Q -- No --> S
R & S --> T{Pagination strategy?}
T -- Cursor-based --> U[Add Connection/Edge/PageInfo types]
T -- Offset-based --> V[Add limit/offset args]
U & V --> W[Validate schema: no circular deps, no orphan types]
W --> X[Generate SDL file + resolver stubs]
X --> Y([Output: GraphQL schema + resolver scaffolding])
@upstash/context7-mcp: Library documentation and examples.| Version | Date | Description |
|---|---|---|
| 1.1.0 | 2026-03-20 | Restructured: moved examples/references, added compatibility/license |
| 1.0.0 | 2026-03-20 | Initial release |