graphql-js
d5fb50a9 - Add valueToLiteral()

Comment changes are shownComment changes are hidden
Commit
4 years ago
Add valueToLiteral() * Adds `valueToLiteral()` which takes an external value and translates it to a literal, allowing for custom scalars to define this behavior. This also adds important changes to Input Coercion, especially for custom scalars: * The value provided to `parseLiteral` is now `ConstValueNode` and the second `variables` argument has been removed. For all built-in scalars this has no effect, but any custom scalars which use complex literals no longer need to do variable reconciliation manually (in fact most do not -- this has been an easy subtle bug to miss). This behavior is possible with the addition of `replaceASTVariables`
Author
Committer
Parents
  • src
    • File
      index.ts
    • type
      • __tests__
        • File
          definition-test.ts
        • File
          scalars-test.ts
      • File
        definition.ts
      • File
        scalars.ts
    • utilities
      • __tests__
        • File
          coerceInputValue-test.ts
        • File
          replaceVariables-test.ts
        • File
          valueToLiteral-test.ts
      • File
        coerceInputValue.ts
      • File
        index.ts
      • File
        replaceVariables.ts
      • File
        valueToLiteral.ts
    • validation/rules
      • File
        ValuesOfCorrectTypeRule.ts
Loading