Skip to content

Commit 8262512

Browse files
Initial Commit
1 parent ce58081 commit 8262512

17 files changed

+3045
-1
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -128,3 +128,6 @@ dist
128128
.yarn/build-state.yml
129129
.yarn/install-state.gz
130130
.pnp.*
131+
132+
router/router
133+
.env

README.md

+27-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,27 @@
1-
# example-coprocessor-helloworld
1+
# External Authenticating using a Coprocessor
2+
3+
This repository demonstrates how to setup a skeleton coprocessor that simply logs the `payload` from the Router.
4+
5+
## Running the Example
6+
7+
> Note: To run this example, you will need a GraphOS Enterprise plan and must create `/router/.env` based on `/router/.env.example` which exports `APOLLO_KEY` and `APOLLO_GRAPH_REF`.
8+
9+
1. Run the subgraph from the `/subgraph` directory with `npm run dev`
10+
1. Run the coprocessor from the `/coprocessor` directory with `npm run dev`
11+
1. In the `/router` directory, download the router by running `./download_router.sh`
12+
1. In the `/router` directory, compose the schema by running `./create_local_schema.sh`
13+
1. In the `/router` directory, run the router by running `./start_router.sh`
14+
15+
Now if you run this code in the browser (http://127.0.0.1:4000/), you will be able to query the router and you will see the `payload` logged in the terminal by the coprocessor.
16+
17+
## Code Highlights
18+
19+
### Coprocessor Configuration
20+
21+
In `router/router-config.yaml`, the coprocessor is configured with the Router to be called on the `router` `request` stage.
22+
23+
### Coprocessor
24+
25+
In `coprocessor/src/index.js`, the coprocessor is setup with `express` to listen to the `/` POST endpoint and respond to the `RouterRequest` stage.
26+
27+
In the `processRouterRequestStage` function, the payload is logged.

0 commit comments

Comments
 (0)