Skip to content

Commit 735c309

Browse files
committed
chore: import maps and example logging
1 parent 993ec7d commit 735c309

3 files changed

Lines changed: 19 additions & 16 deletions

File tree

examples/graphql-yoga/graphql/Subscription/countdown.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,13 @@ export const schema = /* GraphQL */ `
88

99
export const resolver: IFieldResolver<unknown, unknown, { from: number }> =
1010
async function* (_, { from }) {
11-
for (let i = from; i >= 0; i--) {
12-
await new Promise((resolve) => setTimeout(resolve, 1000));
13-
yield { countdown: i };
11+
try {
12+
while (from > 0) {
13+
await new Promise((resolve) => setTimeout(resolve, 1000));
14+
yield { countdown: from };
15+
from--;
16+
}
17+
} finally {
18+
console.info(`Countdown finished${from > 0 ? ` at ${from}` : ""}.`);
1419
}
1520
};

import_map.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
"@preact/signals": "https://esm.sh/*@preact/signals@1.0.3",
99
"@preact/signals-core": "https://esm.sh/*@preact/signals-core@1.0.1",
1010

11-
"@graphql-yoga/common": "https://cdn.skypack.dev/@graphql-yoga/common?dts",
12-
"@graphql-tools/utils": "https://cdn.skypack.dev/@graphql-tools/utils?dts"
11+
"@graphql-tools/schema": "https://cdn.skypack.dev/@graphql-tools/schema?dts",
12+
"@graphql-tools/utils": "https://cdn.skypack.dev/@graphql-tools/utils?dts",
13+
"@graphql-yoga/common": "https://cdn.skypack.dev/@graphql-yoga/common?dts"
1314
}
1415
}

schema.ts

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,18 @@
11
// deno-lint-ignore-file no-explicit-any
22

3-
import type {
4-
IExecutableSchemaDefinition,
5-
} from "https://cdn.skypack.dev/@graphql-tools/schema?dts";
6-
import {
7-
makeExecutableSchema,
8-
} from "https://cdn.skypack.dev/@graphql-tools/schema?dts";
9-
import type {
10-
IFieldResolver,
11-
IResolvers,
12-
} from "https://cdn.skypack.dev/@graphql-tools/utils?dts";
3+
import type { IExecutableSchemaDefinition } from "@graphql-tools/schema";
4+
import { makeExecutableSchema } from "@graphql-tools/schema";
5+
import type { IFieldResolver, IResolvers } from "@graphql-tools/utils";
6+
import type { GraphQLScalarType } from "https://esm.sh/graphql@16.6.0";
137

148
export type Callable = (...args: any[]) => any;
159

1610
export type GraphQLModule = {
1711
schema?: string;
18-
resolver?: IResolvers | IFieldResolver<any, any, any, any>;
12+
resolver?:
13+
| GraphQLScalarType
14+
| IResolvers
15+
| IFieldResolver<any, any, any, any>;
1916
};
2017

2118
export type Manifest = {

0 commit comments

Comments
 (0)