Skip to content

Commit 5942229

Browse files
committed
feat: show off working subscriptions
1 parent 76d2d3d commit 5942229

File tree

4 files changed

+77
-63
lines changed

4 files changed

+77
-63
lines changed

hello-world/api.graphql

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,7 @@
22
### Do not make changes to this file directly
33

44

5-
"""
6-
A date-time string at UTC, such as 2007-12-03T10:15:30Z, compliant with the
7-
`date-time` format outlined in section 5.6 of the RFC 3339 profile of the ISO
8-
8601 standard for representation of dates and times using the Gregorian calendar.
9-
"""
5+
"""Use JavaScript Date object for date/time fields."""
106
scalar DateTime
117

128
"""

hello-world/api/graphql/user.ts

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { schema, settings } from "nexus"
1+
import { schema } from "nexus"
22

33
schema.objectType({
44
name: "User",
@@ -25,31 +25,26 @@ schema.objectType({
2525
},
2626
})
2727

28-
async function* truthStream() {
29-
while (true) {
30-
const answer = [true, false][Math.round(Math.random())]
31-
yield answer
32-
await new Promise((res) => setTimeout(res, 1000))
33-
}
34-
}
35-
3628
schema.subscriptionType({
3729
definition(t) {
38-
// todo t.boolean seems broken
30+
// todo Nexus Schema t.boolean is broken
3931
t.field("truths", {
4032
type: "Boolean",
4133
subscribe() {
4234
return truthStream()
4335
},
36+
// todo Nexus Schema doesn't infer type currently
4437
resolve(answer: boolean) {
4538
return answer
4639
},
4740
})
4841
},
4942
})
5043

51-
settings.change({
52-
server: {
53-
playground: undefined,
54-
},
55-
})
44+
async function* truthStream() {
45+
while (true) {
46+
const answer = [true, false][Math.round(Math.random())]
47+
yield answer
48+
await new Promise((res) => setTimeout(res, 1000))
49+
}
50+
}

hello-world/package-lock.json

Lines changed: 64 additions & 41 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

hello-world/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
"license": "MIT",
55
"repository": "graphql-nexus/examples",
66
"dependencies": {
7-
"nexus": "^0.26.1"
7+
"nexus": "^0.27.0-next.6"
88
},
99
"devDependencies": {
10-
"@types/jest": "26.0.12",
10+
"@types/jest": "26.0.13",
1111
"jest": "26.4.2",
1212
"prettier": "2.1.1",
1313
"ts-jest": "26.3.0"

0 commit comments

Comments
 (0)