Skip to content
SDL → queries · mutations · variables · fragments

GraphQL Query Example Generator

Paste a GraphQL schema and generate runnable example operations — queries and mutations for any root field, with typed variables, a matching JSON block, depth-controlled selection sets and reusable fragments. Parsed entirely in your browser.

01 · Schema (SDL)
5 types · 2 enums · 4 queries · 2 mutations
02 · Operation
Root field
query.graphql
query User($id: ID!) {
  user(id: $id)
}
variables.json
{
  "id": "123"
}
Deep analysis

Reusable fragments & schema map

Fragment
UserFields fragment
fragment UserFields on User {
  posts {
    id
  }
}
Types in schema
Querytype · 4 fields
Mutationtype · 2 fields
Usertype · 3 fields
Posttype · 3 fields
CreatePostInputinput · 2 fields
PostStatusenum · 3 values
Roleenum · 3 values
Field notes

From schema to a runnable call

A GraphQL schema tells you everything about what a server can do, but it doesn't hand you the operation to actually call it. Writing that operation by hand means transcribing the root field, declaring its arguments as variables with exactly the right types, and then building a selection set that walks the returned object graph to the depth you care about — fiddly work that's easy to get subtly wrong, especially the $var: Type! nullability and list markers.

This generator reads the SDL directly, so every name and type in the output is real. It defaults to the production-correct pattern of typed variables — declaring $id: ID!, referencing it in the field call, and emitting a matching JSON object — because that's what keeps an operation reusable, cacheable and free of string-escaping bugs. Input-object arguments are expanded field-by-field so a mutation's payload shape is visible at a glance.

The depth control is the one knob worth understanding: scalars and enums are always selected as leaves, while object relationships are followed only as far as you allow. Depth 2 — scalar fields plus one level of nested objects — is the sweet spot for most calls; raise it when you genuinely need the deeper shape, lower it to avoid over-fetching. When you need to reuse a type's field set across several operations, grab the generated fragment instead of repeating the selection.

Explore the schema's structure first in the GraphQL Schema Visualizer, then generate calls here — and for REST APIs, the OpenAPI Documentation Generator does the equivalent job from a spec.

GraphQL Query Example FAQs

Have more questions? Contact us

Trusted by API & Frontend Engineers

4.8
Based on 1,840 reviews

Paste the SDL, pick the root field, get a correct query with typed variables and a matching JSON block. It saves me from hand-writing selection sets every time I touch a new endpoint. The depth control is exactly the right knob — 2 covers 90% of what I need.

D
Daniel Okafor
Full-stack engineer
June 10, 2026

The mutation support with expanded input objects is the killer feature — I can immediately see the payload shape createPost expects without digging through the schema. Variables come out as real JSON I drop straight into urql. No upload, works on our private schema.

M
Mei Lin
Frontend lead
May 22, 2026

Handles enums and custom scalars sensibly and never emits an empty selection set, which other generators get wrong. I'd love fragment-spread reuse inside the generated query, but the standalone fragment output already covers most of my cases.

T
Tomás Herrera
API engineer
April 18, 2026

I use this in workshops — paste the schema, generate examples live, copy into GraphiQL, run. It makes a new API approachable in seconds and the output is genuinely production-shaped, not toy queries. Pairs perfectly with the schema visualizer.

H
Hannah Brooks
Developer advocate
February 9, 2026

Love using our calculator?

Connected instruments

Related API tools

Learn More

Related Articles

Dive deeper with our expert guides and tutorials related to GraphQL Query Example Generator

Loading articles...

queries · mutations · typed variables · fragments · in-browser · Last reviewed: 2026-06