Skip to content

Supporting Incremental Delivery with @defer/@stream directives #12

@potatosalad

Description

@potatosalad

I wanted to open an issue for discussion of incremental delivery with the @defer and @stream directives in Argo.

Following the specs in graphql/graphql-spec#742, which is now in the "Draft (RFC 2)" state, the following is a potential wire-type solution for dealing with these incremental responses:

schema {
  query: Query
}

type Query {
  root: Object!
}

type Object {
  children: [Object!]!
}
query {
  root {
    required: __typename
    ... @defer {
      deferred_x: __typename
    }
    ... @defer(label: "defer_z") {
      deferred_y: __typename
    }
    children_x: children @stream {
      streamed_x: __typename
    }
    children_y: children @stream(label: "stream_z") {
      streamed_y: __typename
    }
  }
}

The examples below use an ERROR wire type that is an alias to the following:

{
  message: STRING<String>
  location?: {
    line: VARINT<Int>
    column: VARINT<Int>
  }[]
  path?: PATH
  extensions?: DESC_OBJECT
}

In addition, a new wire type referred to as UNION (a tagged union type similar to the one found in BARE).

{
  data?: {
    root: {
      required: STRING<String>
      deferred_x?: STRING<String>
      deferred_y?: STRING<String>
      children_x: {
        streamed_x: STRING<String>
      }[]
      children_y: {
        streamed_y: STRING<String>
      }[]
    }
  }?
  incremental?: UNION {
    <0>: {
      path: PATH
      data: {
        deferred_x: STRING<String>
      }?
      errors?: ERROR[]?
      extensions?: DESC_OBJECT
    }
    <1:"defer_z">: {
      path: PATH
      data: {
        deferred_y: STRING<String>
      }?
      errors?: ERROR[]?
      extensions?: DESC_OBJECT
    }
    <2>: {
      path: PATH
      items: {
        streamed_x: STRING<String>
      }[]
      errors?: ERROR[]?
      extensions?: DESC_OBJECT
    }
    <3:"stream_z">: {
      path: PATH
      items: {
        streamed_y: STRING<String>
      }[]
      errors?: ERROR[]?
      extensions?: DESC_OBJECT
    }
  }[]
  hasNext?: BOOLEAN<Boolean>
  errors?: ERROR[]?
  extensions?: DESC_OBJECT
}

Any initial thoughts or opinions? Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions