Nullability WG ·

Nullability WG meetings · Jump to notes

Agenda

View agenda on GitHub

GraphQL CCN WG – August 2023

To read about the purpose of this subcommittee, please see the README.

This is an open meeting in which anyone in the GraphQL community may attend.

Attendees

NameGitHubOrganizationLocation
Young Min Kim@aprilrdThe Trade DeskSan Francisco, CA, US
Alex Reilly@twofIndependentSan Francisco, CA, US
Martin Bonnin@martinbonninApolloParis, FR
Matt Mahoney@mjmahoneMetaNew York, NY
Benoit Lubek@BoDApolloLyon, FR
Stephen Spalding@fotoetienneNetflixLos Gatos, CA, US
Benjie Gillam@benjieGraphileChandler's Ford, UK

Agenda

  1. Agree to Membership Agreement, Participation & Contribution Guidelines and Code of Conduct (1m, Organizer)
  2. Introduction of attendees (5m, Organizer)
  3. Determine volunteers for note taking (1m, Organizer)
  4. Review agenda (2m, Organizer)
  5. Review previous meeting's action items (5m, Organizer)

Notes

View notes on GitHub

Client Controlled Nullability WG - August 2023

Watch the replay: GraphQL Working Group Meetings on YouTube

Attendees:

  • Martin Bonnin
  • Stephen Spalding
  • Young Min Kim
  • Benoit Lubek
  • Benjie
  • Matt
  • Alex

Notes:

  • Discussion from GraphQL WG: notes, video
  • Proposed Agenda: https://github.com/calvincestari/client-controlled-nullability-wg/pull/1/files
  • Introduction done
  • Stephen: Proceed with only (!)? From 8/3 WG, do we have resolution? There was discussion about whether (?) is essential
  • Benjie: The group present 8/3 was largely the same as CCN subgroup. Hoping to bring it back to WG for a wider audience
  • Benjie: This impacts fragment modularity
  • Young: If we introduce without (?) that will impact the meaning of (!)
  • Benjie: Any queries that have only (!) would need to continue working, even if (?) was added later
  • Benjie: We were missing proponents of (?) at the last meeting (i.e. Lee). We should be feedback before proceeding
  • Stephen: If we decide that (?) is essential, do we include it with the currently proposed propagation behavior, or with simpler semantics where it only flips the nullability of a field and normal GraphQL bubbling behavior is preserved
  • Young: I am in favor of the simpler definition of (?)
  • Matt: bubbling in GraphQL probably should have been done differently. It basically makes it dangerous to use NonNull in a schema. CCN shouldn’t be necessary. One of the lessons we’re learning from Relay is that @required is usually use in places where the function the resolver is calling actually returns a non-null value but the server makes it null just because we don’t want the bubbling behavior
  • Stephen: Consider a (?) addition for the schema SDL. This would be a way for the server to express that this field is semantically nullable. i.e. Null is an expected state. This would mean that the default is for fields to be only null if something goes wrong.
  • Matt:
  • Benije: In GraphQL, the client can dictate the response shape. One interpretation of CCN is allowing the client to control the response shape more - by stating that a certain field cannot (or can) be null. Or by stating that it can or cannot be omitted,
    • Matt points out that when a null bubbles, the response cannot be written safely to normalized store. ? could indicate that omitting that field would be safe, and thus the error should be marked as "safe" for normalized store, e.g. by going into "ccnErrors" or having an extra property. ? would act a little like @skip(if: $var) in that respect, except we don't know the value of $var at runtime.
    • "Omitting" doesn't make sense for list items? So ? and ! only - no [[!]!]! syntax?
    • One reason for giving clients this control is the schema should be "correct" (this thing can be null) but lazy clients should be able to state "I can't be bothered to handle this right now - if this comes through as null then bubble it up". This may be useful when there are multiple clients to the same API - e.g. a fully featured web client and a quick and dirty mobile client.
  • Martin: As an Android developer using Kotlin, I want to be able to have codegen take nullability into account so that I don’t need to handle null case unnecessarily
  • Matt: in the mobile clients I work on, we still handle requests from 2 years ago. If a field can ever be null, it needs to be nullable now otherwise we're messing up a client. Without null bubbling, nullable -> non-nullable requires client to check in errors array on a null "because that can't happen". (Re: Codegen.) Old clients dictating what the schema ought to be is kind of funky.
  • Matt: two classes of error: 1) throw away response, or 2) field shouldn't be null but whatever.
  • Martin: CCN is about who we're optimizing for, currently we're optimizing for what Benjie calls "fully featured web app", but I'd love this proposal to invert this so that you can do something what Benjie calls "quick and dirty" fast in your quick mobile app, and improve later. This can help developers onboard to GraphQL as they don't need to worry about these concerns until a few months into their journey. Feels like ? is the beginning of an answer for this.
  • Benjie: I'd be interested in exploring what ? would mean if it were only on a named fragment definition, and not allowed on fields. I imagine it could catch errors and (as Matt suggests) omit the fields that were solely in the fragment (and don't overlap with other selection sets)
  • Benjie: If ? meant "(make nullable and) omit on null/error", what would ! mean - is it a simple GraphQLNonNull or something else?
    • Young: Maybe we don’t use (?) syntax for that
  • Young: A benefit of directives is discoverability
  • Matt: If we change propagation we need syntax. Directives can’t modify shape.
    • Benjie: what about skip/include?
    • Matt: It’s not beyond local area. Could be modeled with undefined. But a good point that we do sort of change the shape
  • Benjie: - might make sense.
    • { id name -friends { … } }
    • { id name friends @skip(on: [ERROR, NULL]) { … } }
    • We already have the skip directive. We could add an on condition to it
    • Matt: Slightly cleaner directives would be @errorOnNull (for what we’re talking about for ! On nullable fields) and @skipOnError (for ? On non-nullable fields) Which you can still compose (@errorOnNull @skipOnError)
  • Stephen: Conclusions?
    • Young: We’re in alignment (!) only flips nullability and doesn’t change propagation
  • Alex: Can we run multiple ones without committing yet?
  • Benjie: The thing with (!) is that it can be done entirely on the client side.
  • Matt: Reminds me of Rust language proposals. The first thing is “what is the behavior?”. Provide the ability to do the behavior and then if there’s better syntax it’s just a code mod.
    • Directive first. Once its clear that this is that it should mean
  • Benjie: Hard to express lists with a directive
  • Stephen: Can this just be an initial limitation that you can’t express fine grained nullability within lists using CCN?
  • Alex: Directive was brought up at the first meeting, we turned this down for some reason.
    • Matt: I recall that Lee doesn’t like for directive to change the shape of response
    • Lee’s response to directives: “I'm in strong support for syntax rather than directive for this. Directives pollute a query, you may end up adding a lot more directive text than field text! ! is a really natural syntax especially for Kotlin/Swift.”
  • Benjie: propose that we bring the same discussion to WG and hope that we have some more representation. I’ll talk to Lee. Anyone else?
    • Matt: Jordan Eldrige