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

Rename Coercion functions #2357

Closed
andimarek opened this issue Jan 18, 2020 · 2 comments
Closed

Rename Coercion functions #2357

andimarek opened this issue Jan 18, 2020 · 2 comments

Comments

@andimarek
Copy link
Contributor

The Coercion functions for Scalars are currently named:

  1. serialize: this is result or output coercion
  2. parseValue: this is runtime object input coercion
  3. parseLiteral: this is Ast literal input coercion
  4. (See Convert arbitrary scalar values into ASTs and back #1817): serializeAsLiteral this takes an input value and converts it to an Ast literal

I don't think the current names align very well with the spec: the spec talks about "Result Coercion" and "Input Coercion". Also parseValue doesn't parse anything, but convert a runtime input value to an internal value.

In my mental model parseValue and parseLiteral produce a internalInputValue and serializeAsLiteral converts the internalInputValue to a literal.

First rough idea (I am sure we can do better, just to start the discussion)

  1. coerceOutput or coerceResult (the spec talks about result coercion, but output would mirror input)
  2. coerceInputValue
  3. coerceInputLiteral
  4. coerceInternalValueAsLiteral

In GraphQL Java we are also thinking about renaming (and adding a 4th one) and it would be great to have a discussion about a more clear naming.

@sungam3r
Copy link

sungam3r commented Mar 14, 2021

Just for information. GraphQL.NET in v4 has 7 methods for any scalar . See ScalarGraphType.

yaacovCR added a commit to yaacovCR/graphql-js that referenced this issue Oct 7, 2024
yaacovCR added a commit to yaacovCR/graphql-js that referenced this issue Oct 13, 2024
yaacovCR added a commit to yaacovCR/graphql-js that referenced this issue Oct 13, 2024
yaacovCR added a commit that referenced this issue Oct 13, 2024
the new method was introduced in #3812 with upgrade path improved in
#4209.

This PR completes polishes this work a bit:

1. The method is renamed to `coerceInputLiteral()` following the naming
convention suggested in #2357, with the other methods to be renamed in
later PRs.
2. The type of the method `GraphQLScalarInputLiteralCoercer` is
exported, which was not done in the initial work. The old
`GraphQLScalarLiteralParser` type is deprecated.
@yaacovCR
Copy link
Contributor

Closed by #4218 and #4241

yaacovCR added a commit that referenced this issue Oct 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants