Nullability WG ·

Nullability WG meetings · Jump to notes

Agenda

View agenda on GitHub

Nullability WG — September 2024

The Nullability WG (Working Group) is a subcommittee of the GraphQL Spec WG tasked with improving the experience around nullability in GraphQL. It was previously known as the Client Controlled Nullability WG, but now includes server-side solutions within its scope also.

This is an open meeting in which anyone in the GraphQL community may attend. We typically meet on the last Wednesday

Attendees

NameGitHubOrganizationLocation
Alex Reilly@twofIndependentSan Francisco, US
Benjie Gillam@benjieGraphileChandler's Ford, UK
Benoit Lubek@bodApolloLyon, FR
Calvin Cestari@calvincestariApollo (Swift)Vancouver, CA
Martin Bonnin@martinbonninApolloParis, FR
Jordan Eldredge@CaptbaritoneMeta (Relay)San Francisco, US
Itamar Kestenbaum@itamarkMetaPlainsboro, NJ
Stephen Spalding@fotoetienneNetflixLos Gatos, CA, US
Alf Lervåg@alfSiktOslo, NO
Ernie Turner@ernieturnerCoinbaseBozeman, MT

Agenda

  1. Agree to Membership Agreement, Participation & Contribution Guidelines and Code of Conduct (1m, Host)
  2. Introduction of attendees (5m, Host)
  3. Determine volunteers for note taking (1m, Host)
  4. Review agenda (2m, Host)
  5. Review previous meeting's action items (5m, Host)
  6. Introducing the nullability trifecta (10m, Benjie)
    • client-side localized error handling (e.g. throw on error) - brings the errors back into the data tree
    • no null bubbling - for smart clients, fixes issues writing to normalized caches when errors occur, but requires clients to reproduce null-bubbling
    • semantic non-null - indicates what the true nullability of something is, excluding the possibility of errors
  7. Introducing GraphQL-TOE (5m, Benjie)
    • Already has a PR open against URQL
    • Should also work with window.fetch()-style implementations, and useQuery() from Apollo Client
  8. An early implementation in graphql-js (25m, Benjie)
    • How should introspection work for backwards compatibility?
    • Doesn't use the latest proposed syntax; let's revisit this now the implementation and application is more concrete
  9. Incorporate graphql-toe and the graphql-js pre-release into blog post? (15m, Benjie)
    • If we can agree on some things above and fix the implementation, we can let people get hands on with the full nullability trifecta.

Notes

View notes on GitHub

Client Controlled Nullability WG - September 2024

Watch the replay: GraphQL Working Group Meetings on YouTube

Attendees:

  • Alf
  • Benjie
  • Itamar
  • Martin
  • Benoit
  • Ernie
  • Alex
  • Calvin
  • Stephen

Agenda: https://github.com/graphql/nullability-wg/blob/main/agendas/2024/09-Sep/25-nullability-wg-september-2024.md

Determine volunteers for note taking (1m, Host)

  • Alex

Review previous meeting's action items (5m, Host)

Introducing the nullability trifecta (10m, Benjie)

  • client-side localized error handling (e.g. throw on error) - brings the errors back into the data tree
  • no null bubbling - for smart clients, fixes issues writing to normalized caches when errors occur, but requires clients to reproduce null-bubbling
  • semantic non-null - indicates what the true nullability of something is, excluding the possibility of errors
  • Tying them all together gives end users a really good experience
  • If you take errors out of the equation by throwing them up front, then semantic and strict non-null effectively just become non-null for application developers
  • Thoughts?
    • None

Introducing GraphQL-TOE (5m, Benjie)

  • Already has a PR open against URQL
  • Should also work with window.fetch()-style implementations, and useQuery() from Apollo Client
  • If you ever read from a field with an error associated with it, an error will be thrown
  • Converts attempts to read fields with errors to exceptions in JS.
  • Relay itself wouldn’t support this, but other clients could make use of it
  • Even the simplest naive clients could make use of it
  • Any field can error.
  • If there is no data then it will immediately throw.
  • Changes the programming model to require try/catch.
  • Integrating with useFragments()?
    • Main issue: fragments doesn’t know what the path is.

An early implementation in graphql-js (25m, Benjie)

  • How should introspection work for backwards compatibility?
  • Doesn't use the latest proposed syntax; let's revisit this now the implementation and application is more concrete
  • Using asterisk syntax instead of document directives because document directives are harder to implement
  • Things are non-final, but it opens up a way to start trying out semantic nullability
  • There is also another library Benjie created called graphql-sock
  • Thoughts?
    • Is the asterisk syntax final?
      • No it’s just a stand-in for now
    • We’ll talk more about syntax later

Incorporate graphql-toe and the graphql-js pre-release into blog post? (15m, Benjie)

  • If we can agree on some things above and fix the implementation, we can let people get hands on with the full nullability trifecta.
  • If we focus on how people/tools will actually be using this, then we’re mostly interested in more strict non-nulls. The semantic non-nulls are not as important.
  • By disabling null-bubbling on the request the client is basically saying that it will handle the errors. then everything will be semantically non-null (no bangs, just asterisk).
  • The client says: I will handle the errors. The server gives back the schema with more bangs in it and nicer types for the user. Now the bang means non-null and there is some ambiguity.
  • If the client passes on the schema to some other tool that is not aware of the fact that the schema was fetched with the new-mode context then this could be problematic.
  • Stephen comments that it makes sense that when we’re in new-mode then we get the exact same information. We can switch it … (lost the thread)
  • New mode for stupid clients: If there is an error then stop processing.
  • New mode for smart clients: (se above)
  • Is there any value in a new mode with null bubbling? Benjie has not seen any.
  • We need more of a community call to action.
  • Apollo-folks: What do we do to communicate with the users? Martin will ask.
  • The old syntax is important in legacy projects. If you use tools that generate from the GraphQL SDL and you can’t move to newer tools, then we need to support the old syntax for a good while.
  • Tooling for converting old-syntax to new-syntax and new-syntax to old-syntax is easy to make, see for instance graphql-sock.

Syntax discussion (All)

  • There are three options on the table, (Double bang, asterisk, question mark for null)
  • Syntax will basically be consistent for application users since they’ll be translated through their smart clients.
<table> <tr> <td> Nullable </td> <td>String </td> <td>String? </td> <td>String </td> </tr> <tr> <td>Semantic Non-nullable </td> <td>String* </td> <td>String </td> <td>String! </td> </tr> <tr> <td>Strict Non-nullable </td> <td>String! </td> <td>String! </td> <td>String!! </td> </tr> <tr> <td>Requires Document Directive </td> <td>No </td> <td>Yes </td> <td>Yes </td> </tr> <tr> <td>Benefits </td> <td>Better for evolution </td> <td>Semantic Non-null might be the most used type </td> <td>Indicates danger escalation </td> </tr> <tr> <td>Evolution Granularity </td> <td>Field </td> <td>Document </td> <td>Document </td> </tr> </table>