grapql rover and router workflow

 

To compose your supergraph, first we need to create individual schema for example product, review and user graphql schema. And we also need a supergraph.yaml first

subgraphs:
  product:
    routing_url: http://localhost:4001/graphql
    schema:
      file: ./product.graphql   # ← points AT the schema you already wrote
  user:
    routing_url: http://localhost:4002/graphql
    schema:
      file: ./user.graphql
  review:
    routing_url: http://localhost:4003/graphql
    schema:
      file: ./review.graphql


Let's create our supergraph

rover supergraph compose --config ./supergraph.yaml
> supergraph.graphql

If you're using powershell

rover supergraph compose --config ./supergraph.yaml | Out-File -Encoding utf8 supergraph.graphql

We will now have a combined supergraph schema that includes product, review and user graphql.

To perform checks we need to have graphos integration

rover subgraph check my-review@my-variant --schema ./review.graphql --name review

rover subgraph check my-product@my-variant --schema ./product.graphql --name product

rover subgraph check my-user@my-variant --schema ./user.graphql --name user

And it is time to run 

rover dev --supergraph-config ./supergraph.yaml

And then run it using router



# router.yaml
supergraph:
  listen: "0.0.0.0:4000"
  introspection: true

sandbox:
  enabled: true

homepage:
  enabled: false

include_subgraph_errors:
  all: true

c:\tools\router --config router.yaml --supergraph supergraph.graphql 

The github repo for product, review and user schema is here

https://github.com/kepungnzai/graphql-workflow

Comments

Popular posts from this blog

gemini cli getting file not defined error

mongosh install properly