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

Add support for @defer and @stream #224

Closed
andyrichardson opened this issue Aug 13, 2021 · 2 comments
Closed

Add support for @defer and @stream #224

andyrichardson opened this issue Aug 13, 2021 · 2 comments
Labels
question Further information about the library is requested

Comments

@andyrichardson
Copy link

Story

Still in the early stages but thought it would be worth getting this on your radar.

From reading the spec, it looks like the idea is that @defer and @stream directives could allow for incremental resolution of GraphQL queries (i.e. cascading async resolvers could have their responses returned at a later date).

Server side

In the case of the server side, the current protocol should work just fine - the only difference being a query or mutation invocation isn't guaranteed to receive a single next message

Example query (from blog post)

query {
  person(id: "cGVvcGxlOjE=") {
    name
    ...HomeworldFragment @defer(label: "homeworldDefer")
}

fragment HomeworldFragment on Person {
    homeworld {
      name
    }
}

Example protocol response

// First response
{
  "id": "unique-id-1234",
  "type": "next",
  "payload": {
    "data": {
      "person": {
        "name": "Luke Skywalker"
      }
    },
    "hasNext": true
  }
}

// Second response
{
  "id": "unique-id-1234",
  "type": "next",
  "payload": {
    "label": "homeworldDefer",
    "path": ["person"],
    "data": {
      "homeworld": {
        "name": "Tatooine"
      }
    },
    "hasNext": false
  }
}

// Final response
{
  "id": "unique-id-1234",
  "type": "complete"
}

Acceptance criteria

  • Server side library returns multiple responses for queries using @defer or @stream
  • Likely no client side changes required
@n1ru4l
Copy link
Contributor

n1ru4l commented Aug 13, 2021

Already supported, check https://github.com/n1ru4l/graphql-bleeding-edge-playground for a working example


#28
#72

@enisdenjo
Copy link
Owner

enisdenjo commented Aug 13, 2021

As @n1ru4l mentioned, this is already fully supported as of v1.8.0 (since 10 months ago) with #28.

@enisdenjo enisdenjo added the question Further information about the library is requested label Aug 13, 2021
@enisdenjo enisdenjo changed the title Add support for @defer and @steeam Add support for @defer and @stream Aug 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information about the library is requested
Projects
None yet
Development

No branches or pull requests

3 participants