Usage
To enable GraphQL Federation in your GraphQL mock API, click the Federation toggle on the GraphQL page of your mock API.
Usage Example
Below is a simple example showcasing how to set up some GraphQL mock subgraphs in WireMock Cloud, and query them from a supergraph running on your local machine. This example uses Apollo’s Rover CLI tool to run a supergraph locally. If you want to try out this example yourself, ensure that you have Rover installed on your machine. More information on installing Rover can be found here. First, we need to configure some subgraphs to point our supergraph at. We’ll set up three subgraph mock APIs in WireMock Cloud: ausers
subgraph, a products
subgraph and a review
subgraph.
The schemas for each subgraph are below:
Users
Users
Products
Products
Reviews
Reviews
supergraph-config.yaml
.
Rover will use this file to run a supergraph that will call our mock subgraphs.
Paste the following config into the file, replacing the subgraph_url
values with the URLs of your subgraph mock APIs:
supergraph-config.yaml
http://localhost:4000
).
Navigate to your supergraph’s address in your browser where you’ll be greeted with the Apollo Sandbox.
Execute some queries to your supergraph and observe that your subgraph mocks are receiving requests.
To stop your supergraph, enter Ctrl
+ C
in your terminal window where rover is running.
You have successfully creating a GraphQL Federation supergraph, powered by subgraphs running in WireMock Cloud!
For more information on the concepts of GraphQL Federation and designing subgraph schemas, see the official GraphQL
documentation,
as well as the Apollo Federation documentation.
If you have feedback or questions on our GraphQL functionality as it evolves, we’d love to hear from you.
Please get in touch.