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

Preserve sources of variable values #3077

Closed
wants to merge 1 commit into from

Conversation

leebyron
Copy link
Contributor

Depends on #3074

By way of introducing type VariableValues, allows getVariableValues to return both the coerced values as well as the original sources, which are then made available in ExecutionContext.

While variable sources are not used directly here, they're used directly in #3065. This PR is pulled out as a pre-req to aid review

@leebyron leebyron mentioned this pull request May 11, 2021
@leebyron leebyron force-pushed the variable-value-sources branch 2 times, most recently from a271cab to fdb733e Compare May 11, 2021 22:28
@leebyron leebyron force-pushed the default-value-literals branch from 2ee1da8 to 330f01a Compare May 12, 2021 16:44
@leebyron leebyron force-pushed the variable-value-sources branch from fdb733e to 6cecfdd Compare May 12, 2021 16:45
@leebyron leebyron force-pushed the default-value-literals branch from 330f01a to 05db9bd Compare May 13, 2021 02:56
@leebyron leebyron force-pushed the variable-value-sources branch from 6cecfdd to abdec72 Compare May 13, 2021 02:57
@leebyron leebyron force-pushed the default-value-literals branch from 05db9bd to 6c79c53 Compare May 14, 2021 23:26
@leebyron leebyron force-pushed the variable-value-sources branch from abdec72 to 7e9ce87 Compare May 14, 2021 23:27
@leebyron leebyron force-pushed the default-value-literals branch 3 times, most recently from 13e3148 to 780cec2 Compare May 15, 2021 05:03
@leebyron leebyron force-pushed the variable-value-sources branch from 7e9ce87 to ece9e18 Compare May 15, 2021 05:24
@leebyron leebyron force-pushed the default-value-literals branch from 780cec2 to 5686d3e Compare May 15, 2021 06:24
@leebyron leebyron force-pushed the variable-value-sources branch 2 times, most recently from f34abdd to 4b8c50a Compare May 15, 2021 06:40
@leebyron leebyron force-pushed the default-value-literals branch from 5686d3e to 705f154 Compare May 15, 2021 06:51
@leebyron leebyron force-pushed the variable-value-sources branch from 4b8c50a to b967e71 Compare May 15, 2021 06:54
@leebyron leebyron force-pushed the default-value-literals branch from 705f154 to dd31191 Compare May 15, 2021 21:33
@leebyron leebyron force-pushed the variable-value-sources branch from b967e71 to 14d3f8d Compare May 15, 2021 21:34
@leebyron leebyron force-pushed the default-value-literals branch 2 times, most recently from 448367e to e2002dc Compare June 1, 2021 19:49
@leebyron leebyron force-pushed the variable-value-sources branch from 14d3f8d to 25ec49a Compare June 1, 2021 20:17
@leebyron leebyron force-pushed the default-value-literals branch from e2002dc to 5601fd4 Compare June 1, 2021 21:42
@leebyron leebyron force-pushed the variable-value-sources branch from 25ec49a to 0c65c4d Compare June 1, 2021 21:43
@leebyron leebyron force-pushed the default-value-literals branch from 5601fd4 to 3110ca1 Compare June 1, 2021 22:07
@leebyron leebyron force-pushed the variable-value-sources branch from 0c65c4d to cbf56f0 Compare June 1, 2021 22:08
@leebyron leebyron force-pushed the default-value-literals branch from 3110ca1 to f1a14c6 Compare June 3, 2021 17:09
By way of introducing type `VariableValues`, allows `getVariableValues` to return both the coerced values as well as the original sources, which are then made available in `ExecutionContext`.
@leebyron leebyron force-pushed the variable-value-sources branch from cbf56f0 to 6fea731 Compare June 3, 2021 17:09
yaacovCR added a commit that referenced this pull request Sep 29, 2024
[#3077 rebased on
main](#3077).

Depends on #3810

@leebyron comments from original PR:

> By way of introducing type `VariableValues`, allows
`getVariableValues` to return both the coerced values as well as the
original sources, which are then made available in `ExecutionContext`.
> 
> While variable sources are not used directly here, they're used
directly in #3065. This PR is pulled out as a pre-req to aid review

---------

Co-authored-by: Lee Byron <lee.byron@robinhood.com>
@yaacovCR
Copy link
Contributor

Merged as #3811

@yaacovCR yaacovCR closed this Sep 29, 2024
yaacovCR added a commit that referenced this pull request Oct 27, 2024
[#3049 rebased on
main](#3049).

This is the last rebased PR from the original PR stack concluding with
#3049.

* Rebased: #3809 [Original: #3092]
* Rebased: #3810 [Original: #3074]
* Rebased: #3811 [Original: #3077]
* Rebased: #3812 [Original: #3065]
* Rebased: #3813 [Original: #3086]
* Rebased: #3814 (this PR) [Original: #3049]

Update: #3044 and #3145 have been separated from this stack.

Changes from original PR:
1. `astFromValue()` is deprecated instead of being removed.

@leebyron comments from #3049, the original PR:
> Implements
[graphql/graphql-spec#793](graphql/graphql-spec#793)
> 
> * BREAKING: Changes default values from being represented as an
assumed-coerced "internal input value" to a pre-coerced "external input
value" (See chart below).
> This allows programmatically provided default values to be represented
in the same domain as values sent to the service via variable values,
and allows it to have well defined methods for both transforming into a
printed GraphQL literal string for introspection / schema printing (via
`valueToLiteral()`) or coercing into an "internal input value" for use
at runtime (via `coerceInputValue()`)
> To support this change in value type, this PR adds two related
behavioral changes:
>   
> * Adds coercion of default values from external to internal at runtime
(within `coerceInputValue()`)
> * Removes `astFromValue()`, replacing it with `valueToLiteral()` for
use in introspection and schema printing. `astFromValue()` performed
unsafe "uncoercion" to convert an "Internal input value" directly to a
"GraphQL Literal AST", where `valueToLiteral()` performs a well defined
transform from "External input value" to "GraphQL Literal AST".
> * Adds validation of default values during schema validation.
> Since assumed-coerced "internal" values may not pass "external"
validation (for example, Enum values), an additional validation error
has been included which attempts to detect this case and report a
strategy for resolution.
> 
> Here's a broad overview of the intended end state:
> 
> ![GraphQL Value
Flow](https://user-images.githubusercontent.com/50130/118379946-51ac5300-b593-11eb-839f-c483ecfbc875.png)

---------

Co-authored-by: Lee Byron <lee@leebyron.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants