-
Notifications
You must be signed in to change notification settings - Fork 1k
feature: Support defer and stream GraphQL Directives in RedwoodRealtime #9235
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
dthyresson
merged 25 commits into
redwoodjs:main
from
dthyresson:dt-realtime-defer-stream
Oct 31, 2023
Merged
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
af0d080
Adds useDeferStream to Realtime
dthyresson 801990c
Don't overwrite the result with just data and errors to support repea…
dthyresson ee4a4ea
change option to enableDeferStream
dthyresson f1a6c8a
Adds defer and stream examples to RT setup
dthyresson ba27ce4
Rework defer and stream example templates
dthyresson 1423fc8
countdown example now uses Repeater
dthyresson fd7966a
Merge branch 'main' into dt-realtime-defer-stream
dthyresson 8fc3e19
Merge branch 'main' into dt-realtime-defer-stream
dthyresson fdf42b0
Documents realtime and defer and stream
dthyresson 471cb34
clarify docs of SSE and serverful deploy
dthyresson 8bb557b
Merge branch 'main' into dt-realtime-defer-stream
dthyresson 5332b66
Updates realtime config docs
dthyresson 561b2ab
Support schema coordinates. Adds enable defer to template
dthyresson ef65e05
Merge branch 'main' into dt-realtime-defer-stream
dthyresson 53b2b7c
Update docs/docs/realtime.md
dthyresson 5244e11
Update docs/docs/realtime.md
dthyresson bdf80bd
Remove duplicate enableDeferStream
dthyresson 7576e9d
Update docs/docs/realtime.md
dthyresson 7f1081b
Update docs/docs/realtime.md
dthyresson d8e0432
Update docs/docs/realtime.md
dthyresson 83e4211
Update docs/docs/realtime.md
dthyresson b7748db
Delete packages/cli/src/commands/experimental/templates/defer/.keep
dthyresson c476f75
Delete packages/cli/src/commands/experimental/templates/stream/.keep
dthyresson 41d4b16
Merge branch 'main' into dt-realtime-defer-stream
dthyresson 8489f2d
Adds examples for stream and defer in docs
dthyresson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Adds defer and stream examples to RT setup
- Loading branch information
commit f1a6c8a59b0077905ab34f7ac1e6d6a930cc320c
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
...rc/commands/experimental/templates/defer/fastAndSlowFields/fastAndSlowFields.sdl.template
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| export const schema = gql` | ||
| type Query { | ||
| """ | ||
| A field that resolves fast. | ||
| """ | ||
| fastField: String! @skipAuth | ||
|
|
||
| """ | ||
| A field that resolves slowly. | ||
| Maybe you want to @defer this field ;) | ||
| """ | ||
| slowField(waitFor: Int! = 5000): String @skipAuth | ||
| } | ||
| ` |
17 changes: 17 additions & 0 deletions
17
...src/commands/experimental/templates/defer/fastAndSlowFields/fastAndSlowFields.ts.template
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| import { Repeater } from '@redwoodjs/realtime' | ||
|
|
||
| import { logger } from 'src/lib/logger' | ||
|
|
||
| const wait = (time: number) => | ||
| new Promise((resolve) => setTimeout(resolve, time)) | ||
|
|
||
| export const fastField = async () => { | ||
| await wait(100) | ||
| return 'I am speedyyy' | ||
| } | ||
|
|
||
| export const slowField = async (_, { waitFor = 5000 }) => { | ||
| logger.debug('waiting on slowField') | ||
| await wait(waitFor) | ||
| return 'I am slowey' | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
packages/cli/src/commands/experimental/templates/stream/alphabet/alphabet.sdl.template
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| export const schema = gql` | ||
| type Query { | ||
| """ | ||
| A field that spells out the letters of the alphabet | ||
| Maybe you want to @stream this field ;) | ||
| """ | ||
| alphabet: [String!]! @skipAuth | ||
| } | ||
| ` |
30 changes: 30 additions & 0 deletions
30
packages/cli/src/commands/experimental/templates/stream/alphabet/alphabet.ts.template
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| import { Repeater } from '@redwoodjs/realtime' | ||
|
|
||
| import { logger } from 'src/lib/logger' | ||
|
|
||
| export const alphabet = async () => { | ||
| return new Repeater<string>(async (push, stop) => { | ||
| const values = ['a', 'b', 'c', 'd', 'e', 'f', 'g'] | ||
| const publish = () => { | ||
| const value = values.shift() | ||
|
|
||
| if (value) { | ||
| logger.debug({ value }, 'publishing') | ||
| push(value) | ||
| } | ||
|
|
||
| if (values.length === 0) { | ||
| stop() | ||
| } | ||
| } | ||
|
|
||
| const interval = setInterval(publish, 1000) | ||
|
|
||
| stop.then(() => { | ||
| logger.debug('cancel') | ||
| clearInterval(interval) | ||
| }) | ||
|
|
||
| publish() | ||
| }) | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.