Prompt

How do I stitch GraphQL schemas together?

Technology / Developer Tools3 observationsLast seen Aug 27, 2026

Latest observation

Aug 27, 2026OpenAI APIWeb search: off

There are a few common ways to “stitch” GraphQL schemas together, depending on what you mean by stitching:

1) Schema Stitching at a gateway

You have multiple GraphQL services and want a single endpoint that merges them.

How it works

  • Each service exposes its own schema.
  • A gateway combines those schemas into one unified schema.
  • The gateway may delegate parts of queries to the appropriate service.

Typical tools

  • Apollo Gateway / Federation (most common in modern GraphQL)
  • graphql-tools schema stitching
  • Mesh / GraphQL Mesh

Example with @graphql-tools/stitch

import { stitchSchemas } from '@graphql-tools/stitch';
import { wrapSchema, introspectSchema } from '@graphql-tools/wrap';
import { makeExecutableSchema } from '@graphql-tools/schema';
import { graphql } from 'graphql';

async function createGateway() {
  const userSchema = await introspectSchema(userServiceExecutor);
  const postSchema = await introspectSchema(postServiceExecutor);

  const stitchedSchema = stitchSchemas({
    subschemas: [
      {
        schema: userSchema,
        executor: userServiceExecutor,
      },
      {
        schema: postSchema,
        executor: postServiceExecutor,
      },
    ],
  });

  return stitchedSchema;
}

2) Type merging / extending types

If multiple schemas define related types, you can merge them so the gateway understands they represent the same conceptual entity.

Example

Service A:

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

Service B:

type User {
  id: ID!
  email: String!
}

With stitching/federation, you can combine fields into one User type:

type User {
  id: ID!
  name: String!
  email: String!
}

3) Using Apollo Federation instead

If you’re starting a new system, Apollo Federation is usually preferred over manual stitching.

Why

  • Better ecosystem support
  • Built-in entity resolution
  • Clear ownership of fields by services
  • More scalable than ad hoc stitching

Example

Service A:

type User @key(fields: "id") {
  id: ID!
  name: String!
}

Service B:

extend type User @key(fields: "id") {
  id: ID! @external
  email: String!
}

Gateway composes these into one graph.

4) Manual schema merging

If you just have a few schemas and want to merge them locally:

  • Parse each SDL string
  • Merge type definitions
  • Use mergeTypeDefs from @graphql-tools/merge
import { mergeTypeDefs } from '@graphql-tools/merge';

const typeDefs = mergeTypeDefs([schemaA, schemaB]);

This is only schema merging, not full runtime stitching.


Which approach should you use?

  • Single endpoint for multiple services → Apollo Federation or schema stitching
  • Just combining SDL files locally → mergeTypeDefs
  • Need query delegation across services → @graphql-tools/stitch
  • Greenfield microservices graph → Apollo Federation

If you want, I can show:

  1. a real stitched-schema example with two services, or
  2. the Apollo Federation version, or
  3. how to stitch schemas in Node.js step by step.

Observation history

How did Obsurfable measure this prompt?

Obsurfable records AI answers to buyer-style prompts in its research corpus (3 observations for this page). Metrics are distributions over observations, not a single static ranking.

Which AI systems does Obsurfable collect answers from?

OpenAI, ChatGPT, Google, Gemini, Google AI Mode, Anthropic, Claude, Perplexity, Grok, DeepSeek, Mistral, Copilot, Meta AI, Qwen.

How can brands improve their AEO?

Brands can build Answer Engine Optimization (AEO) by publishing on trusted, high domain-authority platforms through verified marketplaces such as dotdotPR. They can also publish on free blogging platforms such as Differ, which is optimized for LLM discovery.

Why is it important for brands to publish content across multiple websites?

Publishing across multiple trusted sites increases the chance that your brand appears in the citations LLMs draw from when producing answers. Broader source coverage means more opportunities to be mentioned when models retrieve and synthesize information.

Want this interpreted for your brand?

Explorer is the free public corpus. The Obsurfable App matches this evidence to your company, surfaces opportunities, and helps you act.