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

GraphQL · Function

makeExecutableSchema

makeExecutableSchema combines GraphQL type definitions with resolvers to produce an executable schema. The result can be passed to a graphql-js-based server.

How it works

makeExecutableSchema combines GraphQL SDL and resolver maps into an executable schema. The resulting schema can be passed to a graphql-js server or used directly to execute operations.

Syntax

makeExecutableSchema({ typeDefs, resolvers })

Parameters

NameTypeDescription
typeDefsDocumentNode or SDL stringGraphQL schema definition language documents describing the types and fields.
resolversResolver mapResolver functions and resolver maps implementing the schema fields.

Returns

An executable GraphQL schema.

Key points

  • The function is provided by the @graphql-tools/schema package.
  • Create the executable schema by passing SDL definitions and resolver implementations in one options object.
  • An executable schema can be exported from a generated module for reuse by application code.
  • The returned schema is compatible with GraphQL servers built on graphql-js.

Common mistakes

  • The type definitions and resolvers must be supplied together in the options object so the schema has both its structure and behavior.

Example: Build and query an executable schema

import { makeExecutableSchema } from "@graphql-tools/schema";
import { graphql } from "graphql";

const typeDefs = `
  type Query { greeting: String! }
`;

const resolvers = {
  Query: { greeting: () => "Hello, GraphQL!" },
};

const schema = makeExecutableSchema({ typeDefs, resolvers });
const result = await graphql({ schema, source: "{ greeting }" });
console.log(result.data);

This builds a runnable schema from SDL type definitions and matching resolver functions, then executes a query against it.

When to use it

Create a schema for a GraphQL server

Server construction

Run queries against a schema during development or testing

Local execution

Add middleware around an executable schema

Schema composition

Interview questions

QWhat does makeExecutableSchema produce?

makeExecutableSchema creates an executable GraphQL schema from type definitions and resolvers. The returned schema can be handed to a graphql-js-based server.

Follow-up: Why are both inputs needed? SDL describes the schema contract, while resolvers provide the runtime field behavior.

QWhat are the main inputs?

The function accepts an options object containing typeDefs and resolvers. The example on the official GraphQL site imports it from @graphql-tools/schema.

Follow-up: What would happen if a field had no resolver? GraphQL may use its default field resolver, but custom behavior must be supplied through the resolver map.

QHow is the result used?

After construction, the executable schema is suitable for use by a GraphQL server. It can also be composed with middleware before serving requests.

Follow-up: Why apply middleware after creation? Middleware can wrap schema execution or field behavior without changing the SDL definition itself.

  • typeDefs
  • resolvers
  • graphql-js
  • applyMiddleware

Source: Tools and Libraries. Checked 2026-10-15.