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 #3811

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Commits on Sep 17, 2024

  1. Preserve defaultValue literals

    Fixes graphql#3051
    
    This change solves the problem of default values defined via SDL not always resolving correctly through introspection by preserving the original GraphQL literal in the schema definition. This changes argument and input field definitions `defaultValue` field from just the "value" to a new `GraphQLDefaultValueUsage` type which contains either -- but not both -- "value" and "literal" fields.
    
    Here is the flow for how a default value defined in an SDL would be converted into a functional schema and back to an SDL:
    
    **Before this change:**
    
    ```
    (SDL) --parse-> (AST) --coerceInputLiteral--> (defaultValue config) --valueToAST--> (AST) --print --> (SDL)
    ```
    
    `coerceInputLiteral` performs coercion which is a one-way function, and `valueToAST` is unsafe and set to be deprecated in graphql#3049.
    
    **After this change:**
    
    ```
    (SDL) --parse-> (defaultValue literal config) --print --> (SDL)
    ```
    leebyron authored and yaacovCR committed Sep 17, 2024
    Configuration menu
    Copy the full SHA
    fdce4b2 View commit details
    Browse the repository at this point in the history
  2. Preserve sources of variable values

    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 authored and yaacovCR committed Sep 17, 2024
    Configuration menu
    Copy the full SHA
    55b9361 View commit details
    Browse the repository at this point in the history