graphql-spec icon indicating copy to clipboard operation
graphql-spec copied to clipboard

add spec edits for references

Open yaacovCR opened this issue 2 years ago • 1 comments

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.

yaacovCR avatar Nov 03 '22 18:11 yaacovCR

Deploy Preview for graphql-spec-draft ready!

Name Link
Latest commit f98ca57a97275d39a12d146adce2d366494b25ee
Latest deploy log https://app.netlify.com/sites/graphql-spec-draft/deploys/636406a1b5af41000897adf6
Deploy Preview https://deploy-preview-998--graphql-spec-draft.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

netlify[bot] avatar Nov 03 '22 18:11 netlify[bot]