Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

GraphQL · Const

SDL

SDL, or Schema Definition Language, is GraphQL’s language-agnostic notation for defining the types and fields exposed by a service. Server libraries can use those declarations while resolver functions separately provide field data.

How it works

SDL is GraphQL’s language-agnostic notation for describing an API schema. It declares types and fields, while the implementation supplies resolver functions that return each field’s data.

Syntax

type TypeName {
  fieldName: FieldType
}

Key points

  • SDL is commonly called the schema definition language.
  • Libraries may use SDL to make defining types and fields more ergonomic.
  • Resolvers for fields are written separately from the SDL declarations.
  • SDL resembles GraphQL’s query language, making schema examples easier to read.
  • SDL lets developers discuss schemas without depending on a particular implementation language.
  • GraphQL defines six named type-definition categories: Object, Scalar, Enum, Interface, Union, and Input Object.

Common mistakes

  • SDL describes the schema, but resolver functions still need to be implemented separately for fields.

Example: A small GraphQL schema

type Query {
  book: Book
}

type Book {
  title: String!
  author: String!
}

This SDL declares the query entry point and the fields available on a Book.

When to use it

Language-neutral schema design

Define a GraphQL API contract independently of server-language details.

Client-facing API shape

Declare the fields and types that client operations can request.

Resolver-based server implementation

Pair schema declarations with separately implemented field resolvers.

Interview questions

QWhat is GraphQL SDL, and what is its role?

SDL is a language-agnostic way to define a GraphQL service’s schema. It describes the types and fields clients may query, while resolver functions provide the corresponding data.

Follow-up: How can a service define a schema without SDL? It can compile the schema from code that provides data for its fields, depending on the library.

QWhy is SDL useful for explaining GraphQL schemas?

SDL lets documentation and schema structure be discussed without choosing a programming language. This makes examples portable across GraphQL server implementations.

Follow-up: Why use SDL in a guide? It resembles GraphQL’s query language and avoids tying the explanation to one programming language.

QHow does SDL relate to validation and execution?

A schema written in SDL defines the types and fields that make up the service’s possible data. Incoming requests are then validated and executed against that schema.

Follow-up: What does the schema enable for clients? Clients can use it to send queries whose results are predictable.

  • Schemas and Types
  • Object types
  • Scalar types
  • Enum types
  • Interface types
  • Union types
  • Input Object types
  • Resolvers

Source: Schemas and Types. Checked 2026-10-15.