Skip to content

Commit

Permalink
chore: import maps and example logging
Browse files Browse the repository at this point in the history
  • Loading branch information
vicary committed Oct 26, 2022
1 parent 993ec7d commit 735c309
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 16 deletions.
11 changes: 8 additions & 3 deletions examples/graphql-yoga/graphql/Subscription/countdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,13 @@ export const schema = /* GraphQL */ `

export const resolver: IFieldResolver<unknown, unknown, { from: number }> =
async function* (_, { from }) {
for (let i = from; i >= 0; i--) {
await new Promise((resolve) => setTimeout(resolve, 1000));
yield { countdown: i };
try {
while (from > 0) {
await new Promise((resolve) => setTimeout(resolve, 1000));
yield { countdown: from };
from--;
}
} finally {
console.info(`Countdown finished${from > 0 ? ` at ${from}` : ""}.`);
}
};
5 changes: 3 additions & 2 deletions import_map.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"@preact/signals": "https://esm.sh/*@preact/signals@1.0.3",
"@preact/signals-core": "https://esm.sh/*@preact/signals-core@1.0.1",

"@graphql-yoga/common": "https://cdn.skypack.dev/@graphql-yoga/common?dts",
"@graphql-tools/utils": "https://cdn.skypack.dev/@graphql-tools/utils?dts"
"@graphql-tools/schema": "https://cdn.skypack.dev/@graphql-tools/schema?dts",
"@graphql-tools/utils": "https://cdn.skypack.dev/@graphql-tools/utils?dts",
"@graphql-yoga/common": "https://cdn.skypack.dev/@graphql-yoga/common?dts"
}
}
19 changes: 8 additions & 11 deletions schema.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
// deno-lint-ignore-file no-explicit-any

import type {
IExecutableSchemaDefinition,
} from "https://cdn.skypack.dev/@graphql-tools/schema?dts";
import {
makeExecutableSchema,
} from "https://cdn.skypack.dev/@graphql-tools/schema?dts";
import type {
IFieldResolver,
IResolvers,
} from "https://cdn.skypack.dev/@graphql-tools/utils?dts";
import type { IExecutableSchemaDefinition } from "@graphql-tools/schema";
import { makeExecutableSchema } from "@graphql-tools/schema";
import type { IFieldResolver, IResolvers } from "@graphql-tools/utils";
import type { GraphQLScalarType } from "https://esm.sh/graphql@16.6.0";

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

export type GraphQLModule = {
schema?: string;
resolver?: IResolvers | IFieldResolver<any, any, any, any>;
resolver?:
| GraphQLScalarType
| IResolvers
| IFieldResolver<any, any, any, any>;
};

export type Manifest = {
Expand Down

0 comments on commit 735c309

Please sign in to comment.