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

Update execution docs #1804

Merged
merged 4 commits into from
Nov 15, 2024
Merged

Conversation

mandiwise
Copy link
Contributor

@mandiwise mandiwise commented Oct 30, 2024

Description

This PR contains updated execution content for the Learn docs. Key changes include:

  • Light editing and better linking throughout the Execution page
  • The format for resolver examples is standardized to other examples in the previous page updates
  • A new "Response" page that describes the data and errors keys in detail, including examples for different syntax, validation, and field error scenarios

@benjie @jorydotcom

Copy link

vercel bot commented Oct 30, 2024

@mandiwise is attempting to deploy a commit to the The GraphQL Foundation Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Member

@benjie benjie left a comment

Choose a reason for hiding this comment

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

This is great content! Excellent work! 🙌

src/pages/learn/execution.mdx Outdated Show resolved Hide resolved
src/pages/learn/execution.mdx Outdated Show resolved Hide resolved
src/pages/learn/execution.mdx Outdated Show resolved Hide resolved
src/pages/learn/execution.mdx Outdated Show resolved Hide resolved
src/pages/learn/execution.mdx Outdated Show resolved Hide resolved
src/pages/learn/response.mdx Outdated Show resolved Hide resolved
src/pages/learn/response.mdx Outdated Show resolved Hide resolved
src/pages/learn/response.mdx Outdated Show resolved Hide resolved
src/pages/learn/response.mdx Show resolved Hide resolved
src/pages/learn/response.mdx Outdated Show resolved Hide resolved
Copy link
Member

@benjie benjie left a comment

Choose a reason for hiding this comment

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

I think this is good to go - excellent work 🙌

Copy link

vercel bot commented Nov 8, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
graphql-github-io ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 8, 2024 6:15pm

@benjie benjie merged commit c7f80c8 into graphql:source Nov 15, 2024
4 checks passed
Comment on lines +123 to +125
Notice that our type system claims `appearsIn` will return Enum types with known values, however, this function is returning numbers! Indeed if we look up at the result we'll see that the appropriate values for the Enum type are being returned. What's going on?

This is an example of scalar coercion. The type system knows what to expect and will convert the values returned by a resolver function into something that upholds the API contract. In this case, there may be an Enum defined on our server which uses numbers like `4`, `5`, and `6` internally, but represents them as Enum values in the GraphQL type system.
This is an example of _scalar coercion_. The type system knows what to expect and will convert the values returned by a resolver function into something that upholds the API contract. In this case, there may be an Enum type defined on our server that uses numbers like `4`, `5`, and `6` internally, but represents them as the expected values in the GraphQL type system.

Choose a reason for hiding this comment

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

Hi @mandiwise @benjie, this section is called Scalar coercion but an Enum is used as example. Since these are two separate types, conflating the two could lead to confusion for the readers.

I believe the spec uses the term Result coercion to describe the concept in this section. Maybe the following minor changes could make it clearer:

  • Changing scalar coercion to result coercion
  • Adding an example of the enum coercion implementation e.g.
Episode: {
  NEWHOPE: 4
  EMPIRE: 5
  JEDI: 6 
}

Sorry for the late comment, I just happen to see this PR after it's merged. I'm happy to make contributions if the above makes sense.

Copy link
Member

Choose a reason for hiding this comment

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

I agree the mix of scalar/enum is confusing and would love to see your suggested edits in a PR 👍

mandiwise added a commit to mandiwise/graphql.github.io that referenced this pull request Nov 19, 2024
mandiwise added a commit to mandiwise/graphql.github.io that referenced this pull request Nov 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants