RFC 0 / Strawman

add spec edits for references

Opened on
Updated on

At a glance

Project
GraphQL Spec
Identifier
#998
Stage
RFC 0 / Strawman
Champion
@yaacovCR
Updated
2022-11-09
Latest activity
Added to WG agenda on
Source

Pull request description

References (soft aliases?) are an alternative syntax for fragment metafields such as __fulfilled

The goal is to create an easily manageable way of requesting different types of fragment spread signals. Multiple metafields or signals will likely be necessary, as after incremental delivery lands, operation writers might be interested in whether a spread has been collected, which can be signaled immediately, or whether all of its fields have been delivered, which may happen only later if the spread has been deferred.

references collect all of these potential signals into a single locus within the response ("the reference") and use "selection set"-style syntax to indicate which signals are of interest. For example, after incremental delivery lands, the following might be valid:

query FragmentReferences {
  nodes(ids: [1, 42]) {
    id
    UserFields { selected }: ...userFragment
    SuperUserFields { selected completed}: ...superUserFragment @defer
  }
}

fragment userFragment on User {
  friends {
    count
  }
}

fragment superUserFragment on SuperUser {
  privilegeLevel
}

This would yield the following data right away:

{
  "nodes": [
    {
      "id": 1,
      "UserFields": { "selected": null },
      "friends": { "count": 1234 }
    },
    {
      "id": 42,
      "UserFields": { "selected": null },
      "friends": { "count": 5678 },
      "SuperUserFields": { "selected": null },
    }
  ]
}

And the following additional payload at path nodes.1 when the deferred fields complete:

{
  "SuperUserFields": { "completed": null },
  "privilegeLevel": 20
}

The existing spec edits only describe the "selected" signal. I am working on the completed signal alongside a version of incremental delivery that does not branch execution or duplicate fields.

Timeline

November 2022

  • On the agenda for GraphQL WG

    6 listed attendees · 7 agenda items · 1 linked RFC

    • Agree to Membership Agreement, Participation & Contribution Guidelines and Code of Conduct (1m, Lee)
    • Introduction of attendees (5m, Lee)
    • Determine volunteers for note taking (1m, Lee)
    • Review agenda (2m, Lee)
    • Review previous meeting's action items (5m, Lee)
    • GraphQL Scalars licensing and domain setup (15m, Donna)
    • References (20m, Yaacov) #998
  • Advanced to RFC 0 on by benjie
  • Pull request created on by yaacovCR
  • @yaacovCR committed "add spec edits for references" on