StepZen is now part of IBM. For the most recent product information and updates go to
https://www.ibm.com/products/stepzen

GraphQL Federation

How to Federate GraphQL APIs with StepZen

GraphQL Federation is the concept of connecting two or more GraphQL APIs (or subgraphs) into one unified GraphQL API (or supergraph). Each backend team or domain can build and maintain its own subgraphs independently.

Federation is easier in GraphQL compared to REST because the concept of linking types is naturally built into GraphQL. For example, the following query returns the same answer whether all the results are coming out of one graph or many.

{
   customer (email: "john.doe@example.com) {
       name
       orders {
           createdOn
           delivery {
               status
               statusDate
           }
       }
   }
}

Types of Federation: Query-based and Object-based

StepZen has a very simple construct for federation: two subgraphs link together into a supergraph by connecting the data in one with a query in the other. We call this query-based federation.

Apollo has a different model for federation: the same object is constructed from two or more subgraphs. We call this object-based federation.

At StepZen, we believe that you, as a developer, should have a choice on what the right federation model is for you. That is why we support both models:

  • You can build subgraphs in StepZen, or some other library or tool, and federate them in StepZen. In other words, StepZen federation code is agnostic with how the subgraphs are built. See Federation in StepZen

  • You can build subgraphs in StepZen, or proxy subgraphs not built in StepZen, and then federate them in Apollo. StepZen generates all the right subgraph compatibility that Apollo Federation needs. See Federation in Apollo