Skip to content

Commit a3620af

Browse files
committed
Add coprocessor yaml and fix context in subs subgraph
1 parent 40b91c7 commit a3620af

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

final/nosql-products/src/index.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,15 @@ async function main() {
7272
};
7373
},
7474
},
75-
],
76-
context: async ({ req }) => new ContextValue({ req, server })
75+
]
7776
});
7877

7978
await server.start();
80-
app.use("/", cors(), json(), expressMiddleware(server));
79+
app.use("/", cors(), json(), expressMiddleware(server,
80+
{
81+
context: async ({ req }) => new ContextValue({ req, server })
82+
}
83+
));
8184

8285
httpServer.listen(port, () => {
8386
console.log(`🚀 Subgraph ready at http://localhost:${port}/`);

router/router.yaml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,11 @@ subscription:
4040
subgraphs:
4141
products:
4242
path: /
43-
# This is a top-level key. It MUST define at least one of the two
44-
# sub-keys shown, even if you don't modify its default value.
45-
# rhai:
46-
# # Specify a different Rhai script directory path with this key.
47-
# # The path can be relative or absolute.
48-
# scripts: "/dist/rhai/scripts"
43+
44+
# Co Processor
45+
coprocessor:
46+
url: https://coprocessor-wn3vwa6nlq-ue.a.run.app # Required. Replace with the URL of your coprocessor's HTTP endpoint.
47+
timeout: 2s # The timeout for all coprocessor requests. Defaults to 1 second (1s)
48+
router: # This coprocessor hooks into the `RouterService`
49+
response: # By including this key, the `RouterService` sends a coprocessor request whenever it first receives a client request.
50+
body: true # By including this key the co-processor can modify the body of the response

0 commit comments

Comments
 (0)