Skip to content

Confusion around variables with default values and null value #257

Closed
@cjoudrey

Description

@cjoudrey

While working on an issue in graphql-ruby, I needed clarity on the expected behaviour of variables with default values and null value in the following example:

Query

query ($id: ID = 4) {
  film(filmID: $id) {
    title
  }
}

Variables

{
  "id": null
}

In graphql-js, null takes precedence over the default value of $id and the film resolver receives filmID: null.

The spec suggests the following algorithm for dealing with this case:

screen shot 2017-01-05 at 5 01 15 pm

However, I got a bit confused when I read this:

screen shot 2017-01-05 at 5 02 23 pm

It might just be me, but I got confused with "represent the lack of a value" and "if value does not exist".

Is "represent the lack of a value" misleading?

/cc @leebyron re: #83
/cc @rmosolgo @xuorig what we were talking about

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions