Skip to content

Commit b18d8fb

Browse files
authored
chore: update Deno examples and references (#4203)
* chore: update Deno examples and references - docs are hosted under .com - Deno.serve stabilised a while back - add imports w/o which example scripts wouldn't run - stop using `--unstable` as it's been removed in v2 and isn't serving any significant purpose in examples * fix(examples/deno): correct order of options and handler This is actually printing the full information with `/graphql` path. Previous version didn't work and only default deno print happened.
1 parent de68acb commit b18d8fb

File tree

5 files changed

+15
-12
lines changed

5 files changed

+15
-12
lines changed

examples/deno/index.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
import { serve } from 'https://deno.land/[email protected]/http/server.ts';
21
import { yoga } from './yoga.ts';
32

4-
serve(yoga, {
5-
onListen({ hostname, port }) {
6-
console.log(`Listening on http://${hostname}:${port}${yoga.graphqlEndpoint}`);
3+
Deno.serve(
4+
{
5+
onListen({ hostname, port }) {
6+
console.log(`Listening on http://${hostname}:${port}${yoga.graphqlEndpoint}`);
7+
},
78
},
8-
});
9+
yoga,
10+
);

examples/deno/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"type": "module",
55
"private": true,
66
"scripts": {
7-
"check": "deno test --import-map ../../import-map.json --unstable --allow-env --allow-net --no-check ./test.ts",
8-
"start": "deno run --import-map ../../import-map.json --unstable --allow-env --allow-net index.ts"
7+
"check": "deno test --import-map ../../import-map.json --allow-env --allow-net --no-check ./test.ts",
8+
"start": "deno run --import-map ../../import-map.json --allow-env --allow-net index.ts"
99
}
1010
}

examples/deno/test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { assertEquals } from 'https://deno.land/[email protected]/testing/asserts.ts';
1+
import { assertEquals } from 'jsr:@std/assert';
22
import { yoga } from './yoga.ts';
33

44
Deno.test('Deno example test', async () => {

import-map.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@
1010
"graphql": "npm:graphql",
1111
"dset": "npm:dset",
1212
"@envelop/core": "npm:@envelop/core@5",
13+
"@envelop/instrumentation": "npm:@envelop/instrumentation",
1314
"@envelop/parser-cache": "npm:@envelop/parser-cache",
1415
"@whatwg-node/fetch": "npm:@whatwg-node/fetch",
1516
"@whatwg-node/events": "npm:@whatwg-node/[email protected]",
17+
"@whatwg-node/promise-helpers": "npm:@whatwg-node/promise-helpers",
1618
"@whatwg-node/server": "npm:@whatwg-node/server",
1719
"@repeaterjs/repeater": "npm:@repeaterjs/repeater",
1820
"lru-cache": "npm:lru-cache@^9.0.0"

website/src/content/docs/integrations/integration-with-deno.mdx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ description:
88

99
GraphQL Yoga provides you a cross-platform GraphQL Server. So you can easily integrate it into any
1010
platform besides Node.js.
11-
[Deno is a simple, modern and secure runtime for JavaScript and TypeScript that uses V8 and is built in Rust](https://deno.land/).
11+
[Deno is a simple, modern and secure runtime for JavaScript and TypeScript that uses V8 and is built in Rust](https://deno.com/).
1212
We will use `graphql-yoga` which has an agnostic HTTP handler using
1313
[Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch)'s
1414
[`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request) and
@@ -17,7 +17,7 @@ We will use `graphql-yoga` which has an agnostic HTTP handler using
1717
## Example
1818

1919
Create a `deno.json` file.
20-
[Learn more about import maps](https://deno.land/manual/basics/import_maps)
20+
[Learn more about import maps](https://docs.deno.com/runtime/fundamentals/modules/#managing-third-party-modules-and-libraries)
2121

2222
Create a `deno-yoga.ts` file:
2323

@@ -31,7 +31,6 @@ Create a `deno-yoga.ts` file:
3131

3232
```ts filename="deno-yoga.ts"
3333
import { createSchema, createYoga } from 'graphql-yoga'
34-
import { serve } from 'https://deno.land/[email protected]/http/server.ts'
3534

3635
const yoga = createYoga({
3736
schema: createSchema({
@@ -48,7 +47,7 @@ const yoga = createYoga({
4847
})
4948
})
5049

51-
serve(yoga, {
50+
Deno.serve(yoga, {
5251
onListen({ hostname, port }) {
5352
console.log(`Listening on http://${hostname}:${port}/${yoga.graphqlEndpoint}`)
5453
}

0 commit comments

Comments
 (0)