Skip to content

Remove CoerceArgumentValues() hasValue #1178

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

Closed
wants to merge 1 commit into from
Closed

Conversation

leebyron
Copy link
Collaborator

@leebyron leebyron commented Jul 3, 2025

An alternative to #1056 which fully removes the hasValue variable in favor of hopefully more clear conditions

The original intent of tracking hasValue was to avoid duplication of logic in places where once we've gotten the "value" from whatever source (value, variable, etc) then the rest of the steps are the same. However that's proven to be fragile and hard to read, since values from different sources are in fact handled differently.

This instead removes the concept of hasValue by instead just using more specific conditions like "If __ has an entry named ___, then let ___ be its value"

For future -- I'd love to overhaul the entire "input coercion" to be strict algorithms instead of prose, which seems particularly important for being crisp about what to do with variables.

@leebyron leebyron requested review from benjie and a team July 3, 2025 16:52
@leebyron leebyron added the ✏️ Editorial PR is non-normative or does not influence implementation label Jul 3, 2025
Copy link

netlify bot commented Jul 3, 2025

Deploy Preview for graphql-spec-draft ready!

Name Link
🔨 Latest commit 6da555d
🔍 Latest deploy log https://app.netlify.com/projects/graphql-spec-draft/deploys/6866bc96ccabd0000958175e
😎 Deploy Preview https://deploy-preview-1178--graphql-spec-draft.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@leebyron leebyron force-pushed the lee/coerce-values branch from 00aeec5 to 695b9dd Compare July 3, 2025 17:21
An alternative to #1056 which fully removes the `hasValue` variable in
favor of hopefully more clear conditions
- Otherwise if {variableDefinition} has a default value, let it be
{defaultValue}:
- If {defaultValue} is {null}:
- Assert: {variableType} is not a Non-Nullable type.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this language of Assert different from the

If {variableType} is a Non-Nullable type, raise a request error.
above?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

default values have gone through request validation, so an error would have been thrown at validation time. I believe we use Assert in other places where that should be true.

It's a good flag though that this should be more clear. It would be nice for all asserts to link back to the validation rules which allow them to be assertions instead of conditions

@leebyron leebyron mentioned this pull request Jul 4, 2025
@leebyron
Copy link
Collaborator Author

leebyron commented Jul 4, 2025

Closing in favor of #1179

@leebyron leebyron closed this Jul 4, 2025
@leebyron leebyron added the 🌱 Superseded (RFC X) RFC Stage X (See CONTRIBUTING.md) as it has been replaced by a newer proposal label Jul 4, 2025
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 🌱 Superseded (RFC X) RFC Stage X (See CONTRIBUTING.md) as it has been replaced by a newer proposal
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants