Skip to content
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

Update @defer to match the latest RFC #4455

Open
rmosolgo opened this issue Apr 28, 2023 · 3 comments
Open

Update @defer to match the latest RFC #4455

rmosolgo opened this issue Apr 28, 2023 · 3 comments

Comments

@rmosolgo
Copy link
Owner

rmosolgo commented Apr 28, 2023

GraphQL-Pro's @defer and @stream implementations predate the current RFC, but since then, the proposal has been updated and the latest Apollo client has better support for it. GraphQL-Pro should be compatible with the latest spec, but also, I need some way to keep compatibility for old users.

RFC: https://github.com/graphql/graphql-wg/blob/main/rfcs/DeferStream.md

It looks to me like the only difference is whether or not it's allowed on fields -- besides that, GraphQL::Pro::Defer and GraphQL::Pro::Stream look up-to-date to me.

@felipeleusin
Copy link

felipeleusin commented May 12, 2023

There's a new version of the RFC that is about to be approved and that works better with Apollo https://github.com/graphql/graphql-spec/pull/742/files

I was struggling to get defer to work but manually constructing the multipart response with this format (using incremental) did the trick.

Apollo does send a header like multipart/mixed;deferSpec=20220824 that could be used to identify which kind of response to return.

@rmosolgo
Copy link
Owner Author

Interesting, thanks for sharing that, @felipeleusin. I see a couple other differences:

  • @defer or @stream are not allowed on root Mutation or Subscription types
  • Labels must be unique within an operation
  • Subscriptions can't have @defer or @stream unless if: false is provided
  • @stream payloads have items instead of data
  • Defer/stream payloads should be nested in incremental: [...] instead of top-level

@rmosolgo
Copy link
Owner Author

GraphQL-Pro 1.24.6 added incremental: true for responding with the new JSON format.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants