---
name: graphql-schema-generator
description: "Your written-out type, query, and mutation specifications turned into a valid, saveable .graphql file: correct SDL syntax, declared scalars and directives, consistent naming, and nothing added that you did not specify. Use when types, queries, and mutations are already written out in notes and need transcribing into a syntactically valid schema.graphql file without design changes. Do not use for designing the schema from a domain description, or auditing a schema that already exists. Related topics: coding, graphql."
---

# GraphQL Schema Generator

Your written-out type, query, and mutation specifications turned into a valid, saveable .graphql file: correct SDL syntax, declared scalars and directives, consistent naming, and nothing added that you did not specify.

## When to use

Use this skill when types, queries, and mutations are already written out in notes and need transcribing into a syntactically valid schema.graphql file without design changes. Do not use it for designing the schema from a domain description, or auditing a schema that already exists.

## Workflow

1. Ask the user for each input listed below in a single message, skipping any they have already given. Where options are listed, offer them, but accept other answers too.
2. Transcribe every type, field, argument, and return type from the inputs with its given name, so the SDL contains exactly what was specified.
3. Normalise syntax only: list and non-null markers, consistent casing with each rename noted, and no invented fields.
4. Declare each selected scalar and directive with its locations before first use.
5. Order the file as scalars, directives, enums, interfaces, object types, inputs, then Query and Mutation.
6. Check that every referenced type is defined, no field is duplicated, and every mutation returns a type, then output the file with any assumptions listed.

## Inputs

- **Types** (longer free text)
- **Queries** (longer free text)
- **Mutations** (longer free text)
- **Scalars** (choose any: Date, DateTime, JSON, URL, UUID, Email, Long)
- **Directives** (choose any: @auth, @deprecated, @cache, @upper, @rateLimit)
- **File name** (free text, e.g. "schema.graphql")

## Output

The file name on one line, the complete SDL in one fenced graphql block, and a short Assumptions list for any ambiguity resolved in the inputs.

## Prompt template

Fill the inputs into this template and follow it as the full instruction.

### GraphQL Schema Generator

Type up my schema specification as a valid .graphql file.

#### Details
- Types: {{Types}}
- Queries: {{Queries}}
- Mutations: {{Mutations}}
- Scalars: {{Scalars}}
- Directives: {{Directives}}
- File name: {{File name}}

Transcribe the specification faithfully: every type, field, argument, and return type named in the inputs appears in the SDL with the exact names given, and nothing is added beyond what GraphQL requires to make it valid (the schema definition, scalar declarations, directive definitions with their locations). Normalise only syntax, not meaning: list types take the list form, required markers become the non-null bang, and field names keep their given casing unless the inputs mix styles, in which case apply camelCase and note each rename. Declare every selected scalar and every selected custom directive before use, with a comment on where the directive applies. Group the file as scalars, directives, enums, interfaces, object types, input types, then Query and Mutation. Validate the result before returning it: every referenced type is defined, no field is declared twice, and every mutation returns a type. Output the whole file in one fenced block with the file name on the line above it, and list any ambiguity in the inputs that you resolved by assumption.

## Pitfalls

- Adding helpful fields or pagination the specification never mentioned, which turns a transcription into a redesign.
- Using a custom scalar or directive in a field without declaring it, which fails schema load on the first run.
- Silently changing a field's casing without listing the rename, so resolvers written against the notes no longer match.
