- Install dependencies:
yarn install
- Trigger the generate command
yarn generate:froid # generates to ./src/sample/froid/schema.graphql
NOTE: For convenience, this is already completed if you use the main
branch
of this repo
- Set up a new Graph in with a Graph Architecture =
Supergraph
(the default) - Run the rover scripts below to push all subgraph schemas in this demo to your supergraph
rover subgraph publish <your-graph-id>@source --schema ./src/sample/marketplace-listings/schema.graphql --name marketplace-listing-service --routing-url http://localhost:5001/graphql
rover subgraph publish <your-graph-id>@source --schema ./src/sample/reviews/schema.graphql --name reviews-service --routing-url http://localhost:5002/graphql
rover subgraph publish <your-graph-id>@source --schema ./src/sample/froid/schema.graphql --name froid-service --routing-url http://localhost:5000/graphql
- Copy the
.env.example
cp .env.example .env
- Update the
.env
with:APOLLO_KEY
: The service key value from Apollo StudioGRAPH_ID
: The id of the federated graph you set up in Apollo StudioGRAPH_VARIANT
: The name of the variant you want to run based on your Apollo Studio configuration
- Start all of the services:
yarn start
- Navigate to http://localhost:4000/graphql to access the gateway playground
query MarketplaceListingReviews(
$first: Int
$after: String
$listingId: String!
) {
marketplaceListing(listingId: $listingId) {
id
name
reviews(first: $first, after: $after) {
totalCount
pageInfo {
hasNextPage
endCursor
}
edges {
cursor
node {
id
title
rating
}
}
}
}
}
{
"first": 2,
"after": null,
"listingId": "W003547033"
}
query SimilarMarketplaceListings($nodeId: ID!) {
node(id: $nodeId) {
__typename
id
... on MarketplaceListing {
name
similarListings {
id
name
}
}
}
}
{
"nodeId": "TWFya2V0cGxhY2VMaXN0aW5nOnsibGlzdGluZ0lkIjoiVzAwMzU0NzAzMyJ9"
}