Openapi To Graphql Sdl
GraphQL Schema Synthesis

OpenAPI / Swagger to GraphQL SDL Schema Converter

Convert OpenAPI 3.0 REST endpoints, request bodies, and JSON schemas into GraphQL SDL types, queries, mutations, and input definitions.

100% Client-Side Privacy
Zero Server Transmission
Presets:
SDL Options:
OpenAPI / Swagger Spec (YAML / JSON)OpenAPI 3.x (YAML)
# ==============================================================================
# GraphQL SDL Schema synthesized from OpenAPI / Swagger
# Title: Swagger Petstore (1.0.0)
# Base Server: https://petstore3.swagger.io/api/v3
# Generated by ToolsAA 100% Client-Side Engine
# ==============================================================================


"""ISO-8601 compliant datetime representation"""
scalar DateTime

"""Arbitrary unstructured JSON object data"""
scalar JSON


schema {
  query: Query
  mutation: Mutation
}


type Query {
  # --- Pets ---
  """List all pets"""
  listPets(status: ListPetsStatusEnum, limit: Int): [Pet!]!

  """Find pet by ID"""
  getPetById(petId: ID!): Pet!
}


type Mutation {
  # --- Pets ---
  """Create a pet"""
  createPet(input: NewPetInput!): Pet!

  """Update an existing pet"""
  updatePet(petId: ID!, input: NewPetInput!): Pet!

  """Deletes a pet"""
  deletePet(petId: ID!): Boolean!
}


enum NewPetStatusEnum {
  AVAILABLE
  PENDING
  SOLD
}


enum PetStatusEnum {
  AVAILABLE
  PENDING
  SOLD
}


enum ListPetsStatusEnum {
  AVAILABLE
  PENDING
  SOLD
}


type Category {
  id: ID!
  name: String!
}


type Tag {
  id: ID!
  name: String!
}


type NewPet {
  name: String!
  category: Category
  photoUrls: [String!]!
  tags: [Tag!]
  status: NewPetStatusEnum
}


type Pet {
  id: ID!
  name: String!
  category: Category
  photoUrls: [String!]!
  tags: [Tag!]
  status: PetStatusEnum!
  createdAt: DateTime
}


input CategoryInput {
  id: ID!
  name: String!
}


input TagInput {
  id: ID!
  name: String!
}


input NewPetInput {
  name: String!
  category: CategoryInput
  photoUrls: [String!]!
  tags: [TagInput!]
  status: NewPetStatusEnum
}
5
REST Endpoints Mapped
10
GraphQL Types & Inputs
1.7 KB
Estimated SDL Footprint

Zero-Server Privacy Guarantee

All OpenAPI specs, internal models, and confidential API endpoints are parsed exclusively in your browser memory. Nothing is ever sent to external cloud servers.

Complete GraphQL SDL Synthesis

Automatically synthesizes Query fields from GET requests, Mutation fields with strongly typed inputs from POST/PUT/PATCH/DELETE endpoints, and maps JSON schemas to GraphQL object types.

Production Apollo & Relay Ready

Outputs standard GraphQL Schema Definition Language compliant with Apollo Server, GraphQL Yoga, Nexus, AWS AppSync, Hasura, and client tooling like Codegen.

Technical Reference & Architecture Guide

OpenAPI / Swagger to GraphQL SDL Schema Converter — Reference Guide

Convert OpenAPI 3.0/3.1 and Swagger 2.0 REST endpoints, request bodies, and JSON schemas into GraphQL SDL types, queries, mutations, and input definitions.

Key Parameters & Controls

operationMapping'query-mutation' | 'query-only'

Controls whether REST operations map to both Query and Mutation root types, or restrict all operations to Query.

Default: 'query-mutation'
inputNamingConvention'suffix-input' | 'prefix-input' | 'exact'

Defines the naming convention for GraphQL input object types generated from request bodies.

Default: 'suffix-input'
idFieldMapping'ID' | 'String' | 'Int'

Determines the target GraphQL scalar type for REST URL path parameters and entity identifier fields.

Default: 'ID'
nullableMode'strict-non-null' | 'optional'

Controls whether OpenAPI required schema properties and path parameters are converted with non-nullable '!' markers.

Default: 'strict-non-null'
customScalars'enabled' | 'string-only'

Generates custom GraphQL scalar declarations (DateTime, UUID, JSON) for OpenAPI string formats.

Default: 'enabled'

Pro Tips & Best Practices

Generate Dedicated Input Types

GraphQL strictly separates output object types from argument input object types. Always generate dedicated 'Input' types for OpenAPI request bodies to maintain schema validity.

Use Custom @rest Directives

Attach custom directives such as @rest(path: "...", method: "...") to Query and Mutation fields so backend gateways like Apollo Server or GraphQL Mesh can resolve endpoints effortlessly.

Map oneOf to GraphQL Unions

Translate OpenAPI 'oneOf' schemas featuring a discriminator property into GraphQL union types, wrapping primitive branches into distinct wrapper object types.

Deduplicate Shared Schemas

Map shared components in '#/components/schemas' directly to top-level GraphQL types, ensuring deduplicated and cohesive schema definitions across all endpoints.

Common Gotchas & Troubleshooting

Duplicate type name collision between request body and response payload

Configure the input naming convention to append 'Input' (e.g. 'CreateUserInput') so input object types do not clash with output object types sharing the same schema name.

Unsupported 'anyOf' or primitive 'oneOf' polymorphism in GraphQL

GraphQL unions cannot contain scalar types like String or Int. Encapsulate primitive union branches inside synthetic object types with a 'value' field before exporting.

Missing 200/201 response definition causing schema syntax error

Verify that all OpenAPI path operations specify at least one successful 2xx response schema, or supply a default generic status response object.

Frequently Asked Questions

How does the converter map REST HTTP methods to GraphQL root types?▼

HTTP GET endpoints are converted into root Query fields. HTTP POST, PUT, PATCH, and DELETE endpoints are mapped to root Mutation fields with path and query parameters as typed arguments.

How are OpenAPI $ref schema components resolved in GraphQL SDL?▼

Shared models located in components/schemas or definitions are parsed and exported as reusable GraphQL SDL object and input types, preventing duplicate schema declarations.

Can OpenAPI oneOf and anyOf polymorphic schemas be represented in GraphQL?▼

Yes. When schemas define object-level polymorphism with a discriminator, they are translated into GraphQL union or interface types. Mixed scalar unions are encapsulated in wrapper types.

Is my OpenAPI or Swagger specification uploaded to any external server?▼

No. All parsing, schema transformation, and SDL generation are executed 100% locally in your browser memory. No data is stored, logged, or transmitted.

Which GraphQL engines and frameworks are compatible with the generated SDL?▼

The output complies with standard GraphQL SDL (October 2021 specification), making it directly compatible with Apollo Server, GraphQL Yoga, Nexus, AWS AppSync, and GraphQL Mesh.

Related Tools & Utilities

All Tools →