File tree 1 file changed +35
-0
lines changed
1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -207,6 +207,41 @@ fastify.listen(4000);
207
207
console .log (' Listening to port 4000' );
208
208
```
209
209
210
+ ##### With [ ` Deno ` ] ( https://deno.land/ )
211
+
212
+ ``` ts
213
+ import {
serve }
from ' https://deno.land/[email protected] /http/server.ts' ;
214
+ import { createHandler } from ' https://esm.sh/graphql-http' ;
215
+ import { schema } from ' ./previous-step' ;
216
+
217
+ const handler = createHandler <Request >({ schema });
218
+
219
+ await serve (
220
+ async (req : Request ) => {
221
+ const [path, _search] = req .url .split (' ?' );
222
+ if (! path .endsWith (' /graphql' )) {
223
+ return new Response (null , { status: 404 , statusText: ' Not Found' });
224
+ }
225
+
226
+ const headers: Record <string , string > = {};
227
+ req .headers .forEach ((value , key ) => (headers [key ] = value ));
228
+ const [body, init] = await handler ({
229
+ url: req .url ,
230
+ method: req .method ,
231
+ headers ,
232
+ body: await req .text (),
233
+ raw: req ,
234
+ });
235
+ return new Response (body , init );
236
+ },
237
+ {
238
+ port: 4000 ,
239
+ },
240
+ );
241
+
242
+ // Listening to port 4000
243
+ ```
244
+
210
245
#### Use the client
211
246
212
247
``` js
You can’t perform that action at this time.
0 commit comments