A learning example
You can download a presentation here
You'll need to have either: Node version 16 and npm version 7.
The repo also includes a client
folder, which includes the frontend for the an app.
To run the client:
- Open a new terminal window, and navigate to the
client
folder. - Run
npm install & npm start
. This will install all packages in the client and start the application inlocalhost:3000
.
You will work in three main folders:
router
(or gateway)subgraph-projects
subgraph-demands
Server | Port | Description |
---|---|---|
router | 4000 | The backend code for the router |
subgraph-projects | 4001 | The backend code for the projects subgraph. |
subgraph-demands | 4002 | The backend code for the demands subgraph. |
To run the servers in the subgraph-projects
folder:
- Open a new terminal window, and navigate to
subgraph-projects
. - Run
npm install && npm start
. This will install all packages in the main server, then start the main server athttp://localhost:4000
. - In a web browser, open Apollo Studio Sandbox for
http://localhost:4001
. You should be able to run queries against your gateway server. Some test queries are included in the following section. - Check sub-graph projects
rover subgraph check --name projects --schema ./subgraph-projects/projects.graphql ${APOLLO_GRAPH_REF}@current
- Publish sub-graph projects
rover subgraph publish ${APOLLO_GRAPH_REF}@current \
--name projects \
--schema ./subgraph-projects/projects.graphql
To run the servers in the subgraph-demands
folder:
- Open a new terminal window, and navigate to
subgraph-demands
. - Run
npm install && npm start
. This will install all packages in the main server, then start the main server athttp://localhost:4000
. - In a web browser, open Apollo Studio Sandbox for
http://localhost:4002
. You should be able to run queries against your gateway server. Some test queries are included in the following section. - Check sub-graph demands
rover subgraph check --name demands --schema ./subgraph-demands/demands.graphql ${APOLLO_GRAPH_REF}@current
- Publish sub-graph demands
rover subgraph publish ${APOLLO_GRAPH_REF}@current \
--name demands \
--schema ./subgraph-demands/demands.graphql
Run router
APOLLO_KEY=service:Archlet-test-Graph:${APOLLO_KEY} APOLLO_GRAPH_REF=${APOLLO_GRAPH_REF}@current ./router --config ./config.yaml
Schema checks - verify the safety of changes to your graph
Certain changes to your graph's schema (such as removing a field or type) might break one of your application's clients.
You can review the results of schema checks inside Apollo Studio or run a command
rover subgraph check Archlet-test-Graph@current --name projects --schema ./subgraph-projects/projects.graphql
Each change to the schema is labeled either PASS or FAIL.
Schema checks are especially useful when you add them to your CI pipeline.
-
Get all projects
query GetProjects { projects { id name description type biddingTypeId } }
-
Get demands
query GetDemands { demands { id name volume } }