Generator für GraphQL-Typdefinitionen aus JSON
Führung
Generator für GraphQL-Typdefinitionen aus JSON
Paste any JSON object or array and instantly receive a GraphQL Schema Definition Language (SDL) document that describes its shape. The generator walks the JSON tree, infers scalar types, names nested objects, merges array-of-object variants, and emits an optional root Query type so the output is ready to drop into a server like Apollo, Yoga, Mercurius, or graphql-go.
Why a Deterministic JSON to GraphQL SDL Converter Matters
Hand-writing GraphQL types from a sample payload is mechanical but error-prone. A single missed nullable, an inconsistent Int vs Float, or a forgotten non-null marker on a list element can break code generation for every downstream client. A rules-driven generator treats the same JSON sample identically every time, which makes it safe to regenerate on every API change.
Nutzung
- Paste a JSON object or array into the input box, or click Probieren Sie ein Beispiel aus to load a representative payload.
- Legen Sie die Root Type Name if you want something other than
Root. - Wählen Sie einen Field Nullability strategy – strict (
!) for required fields or all nullable for prototyping. - Umschalten ID Detection to auto-promote
idund*Idkeys to the GraphQLIDscalar. - Optionally include a root
Querytype with single-entity and list-entity fields. - Copy the SDL or download it as
schema.graphql.
Funktionen
- Scalar Inference – distinguishes
String,Int,Float,BooleanundIDdeterministically. - Nested Object Types – generates a separate named type for every nested object using PascalCase from the field key.
- Array of Object Merging – unions every field across array items so optional fields are correctly marked.
- Nullable vs Non-Null Toggle – emit strict
!markers or relax everything to nullable for early prototypes. - Auto ID Detection – upgrades
id,userId,orderIdstyle keys to theIDscalar. - Root Query Scaffold – optional
type Query { ... }with single and list resolver signatures. - Nur auf der Client-Seite verfügbar – your JSON never leaves the browser, so the tool is safe for sensitive payloads.
Type Inference Rules
- Integer numbers map to
Int; numbers with a fractional part map toFloat. A field seen as both promotes toFloat. - Strings map to
String. With ID detection on, keys namedidor ending inIdbecomeID. - Booleans map to
Boolean. nullvalues mark the field as nullable so the generated SDL skips the trailing!.- Empty arrays default to
[String]because no element type can be inferred safely. - Arrays of objects merge into one named type; fields missing from any element become nullable automatically.
Who Uses It
- Backend engineers wrapping a REST endpoint or a JSON file in a GraphQL gateway.
- Frontend developers prototyping a schema against a fixture payload before the API is ready.
- API designers documenting third-party response shapes as a typed contract.
- Code-generation pipelines that need a reproducible SDL artefact from a stable JSON sample.
Häufig gestellte Fragen
-
What is GraphQL SDL?
Schema Definition Language is GraphQL's text-based syntax for describing types, fields, queries, and mutations exposed by an API. It uses keywords like type, scalar, enum, and input to declare the shape of data a server can return and the operations a client can call.
-
Why does GraphQL use the ! (non-null) marker?
An exclamation mark after a type declares that the field can never resolve to null. It lets clients skip null-check defensive code and lets the server fail fast if a required value is missing. Without it, GraphQL treats every field as nullable by default.
-
When should a field use the ID scalar instead of String?
The ID scalar is reserved for opaque identifiers used to refetch or cache an object - primary keys, UUIDs, slugs, foreign keys. It is serialised as a string but signals identity rather than display content, which helps clients like Apollo and Relay build their normalised caches correctly.
-
How does GraphQL handle lists of objects in SDL?
Lists are written with square brackets, such as [Order!]!. The inner ! means each element in the list is non-null, and the outer ! means the list itself is non-null. Inferring the right element type from a JSON sample requires unioning the field shapes across every item in the array.
Erweiterungen installieren
IO-Tools zu Ihrem Lieblingsbrowser hinzufügen für sofortigen Zugriff und schnellere Suche
恵 Die Anzeigetafel ist eingetroffen!
Anzeigetafel ist eine unterhaltsame Möglichkeit, Ihre Spiele zu verfolgen. Alle Daten werden in Ihrem Browser gespeichert. Weitere Funktionen folgen in Kürze!
Unverzichtbare Tools
Alle Neuheiten
AlleAktualisieren: Unser neuestes Werkzeug wurde am 20. Juni 2026 hinzugefügt
