Check out a free preview of the full Advanced GraphQL course:
The "Schema Stitching" Lesson is part of the full, Advanced GraphQL course featured in this preview video. Here's what you'd learn in this lesson:

Scott shows how to combine GraphQL APIs from multiple sources, even remote ones.

Get Unlimited Access Now

Transcript from the "Schema Stitching" Lesson

>> Scott Moss: Schema stitching, who here has heard of schema stitching? Awesome, yes schema stitching is actually relatively new. I would say it's something as new as a couple of months ago. I don't know who made it popular. But it's a combination of everybody with AppSync coming out on AWS, and Apollo, doing all this crazy stuff, and then Prisma doing all this awesome stuff too.

[00:00:24] So everybody just came together and figured this out. But basically schema stitching is a way where you can have a GraphQL API, and you can delegate parts of your GraphQL API schema to another GraphQL API. That's either on the same server or remote. So, just to wrap your head around that.

[00:00:48] That means, yeah, you can have more than one GraphQL API on one server, right? Because a GraphQL API is not bound to a server. We just ran a GraphQL query right now, right here without even having a server. For every GraphQL API, you don't need a port exposed.

[00:01:05] So you can put mini GraphQL APIs on one server if you want to. So a schema stitching allows you to have this one schema here, this one API. And for this resolver, I'm gonna delegate to this other API that's on another server, but it resolves here. So it's basically like making a resolver on another API, so you can stitch them together.

[00:01:29] That's basically what it is. It's really complicated, but it comes in handy if you're doing things like creating a GraphQL gateway. Where if you have a gateway that sits in front of many services, some including other GraphQL services, this is like the best thing to do. Because you can just stitch them together.

[00:01:47] You can also just do it manually yourself inside the resolvers, right? But like why do that when you can just delegate directly to the GraphQL, just be done with it. I don't have to like stitch it together myself. So that's schema stitching.