Language-neutral schema design
Define a GraphQL API contract independently of server-language details.
GraphQL · Const
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.
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.
type TypeName {
fieldName: FieldType
}type Query {
book: Book
}
type Book {
title: String!
author: String!
}This SDL declares the query entry point and the fields available on a Book.
Define a GraphQL API contract independently of server-language details.
Declare the fields and types that client operations can request.
Pair schema declarations with separately implemented field resolvers.
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.
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.
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 TypesObject typesScalar typesEnum typesInterface typesUnion typesInput Object typesResolvers