Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Difficult to understand note in GQL spec #529

Open
rex-remind101 opened this issue Oct 30, 2018 · 1 comment
Open

Difficult to understand note in GQL spec #529

rex-remind101 opened this issue Oct 30, 2018 · 1 comment
Assignees
Labels
✏️ Editorial PR is non-normative or does not influence implementation

Comments

@rex-remind101
Copy link

https://facebook.github.io/graphql/June2018/#sec-Null-Value

"The same two methods of representing the lack of a value are possible via variables by either providing the a variable value as null and not providing a variable value at all."

I'd be happy to update this with a PR however I'm not sure what to replace it with.

  1. "the a variable" looks like a grammar mistake.
  2. "[V]ariable" should be called out more explicitly since the paragraph right above speaks of arguments and the two are easily confused for one another.
  3. I'm not entirely sure what this is trying to state. Does it mean, "Using a Variable of value null and not providing a Variable at all are equivalent"? Which would mean null is the same as no value existing for the argument? Doesn't this contradict "The first has explicitly provided null to the argument “arg”, while the second has implicitly not provided a value to the argument “arg”. These two forms may be interpreted differently."?

Once 3 is clarified I'd be happy to open a PR.

@IvanGoncharov
Copy link
Member

"the a variable" looks like a grammar mistake.

@rex-remind101 Agree 👍

"[V]ariable" should be called out more explicitly since the paragraph right above speaks of arguments and the two are easily confused for one another.

I think it would be appropriate to change it to "query variables", similar to other places in the spec.

I'm not entirely sure what this is trying to state. Does it mean, "Using a Variable of value null and not providing a Variable at all are equivalent"? Which would mean null is the same as no value existing for the argument? Doesn't this contradict "The first has explicitly provided null to the argument “arg”, while the second has implicitly not provided a value to the argument “arg”. These two forms may be interpreted differently."?

It's mean if you have the query like that:

query getProfileName($id: ID) {
  profile(id: $id) {
    name
  }
}

And you can't specify id variable you can pass either {} or { id: null }.

Note: there are some differences between specifying null and omitting values.
For example, if you change the query to (note default value):

query getProfileName($id: ID = 1) {
  profile(id: $id) {
    name
  }
}

passing {} will be equavivalent to { profile(id: 1) ...
and { id: null } to { profile(id: null) ...

See 3.g : https://facebook.github.io/graphql/June2018/#CoerceVariableValues()
Same applies to default values for field arguments, see 5.h: https://facebook.github.io/graphql/June2018/#CoerceArgumentValues()

Also, note that resolver can behave differently if it receives null as one of the arguments or if the same argument is omitted. So it's up to resolver to either treat null and omit value as equivalent or attach different semantic meaning to them.

Would be great if you incorporate above two points in your PR.

P.S. Some of the details around null were clarified only recently, here is some background:
#418

@IvanGoncharov IvanGoncharov added the ✏️ Editorial PR is non-normative or does not influence implementation label Oct 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✏️ Editorial PR is non-normative or does not influence implementation
Projects
None yet
Development

No branches or pull requests

2 participants