Skip to content

Support checks if GraphQL argument was set to null or omitted entirelyΒ #518

Closed

Description

@rstoyanchev

By default input arguments in GraphQL are nullable and optional, see Nullable vs Optional, which means an argument can be set to null, or not provided at all. The distinction enables partial updates in mutations where the underlying data storage can also be either set to null or not changed at all.

As described in #140 and #228, when binding an argument via @Argument, there is no way to make such a distinction. You can get a null or an empty Optional for the resulting value, but no way to check if the argument was omitted or not.

We can provide ArgumentValue as a simple container for the underlying value along with a flag for whether it was omitted or not. This could be used as an alternative to @Argument on controller method parameters, or nested within the structure of an @Argument object.

Activity

  1. added this to the 1.1.0 milestone on Oct 21, 2022
  2. self-assigned this
    on Oct 21, 2022
  3. changed the title [-]Support checking if an argument was omitted [/-] [+]Support checking if a GraphQL argument was omitted [/+] on Oct 21, 2022
  4. jord1e commented on Oct 24, 2022

    @jord1e
    Contributor

    @rstoyanchev typo at
    d9f815e#diff-99d081232dfcf90f7ad4241a7e5ad145df4f8166f2bf13d5ab2b0e0775130cbbR1409

    should be

    - if (!bookInput.isOmitted) {
    + if (!bookInput.isOmitted()) {
  5. rstoyanchev commented on Oct 24, 2022

    @rstoyanchev
    ContributorAuthor

    Updated in be9a215.

  6. changed the title [-]Support checking if a GraphQL argument was omitted [/-] [+]Support checks if GraphQL argument was set to `null` or omitted entirely[/+] on Nov 9, 2022
  7. added a commit that references this issue on Feb 2, 2023
    6070e9b
  8. added a commit that references this issue on Feb 13, 2024
    d9f815e
  9. added a commit that references this issue on May 13, 2024
    966ba36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions