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

Add example of variable coercion failure #289

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

Conversation

wheresrhys
Copy link

Adds a concrete example to the variable coercion error

Adds a concrete example to the variable coercion error
Copy link

linux-foundation-easycla bot commented Feb 1, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: wheresrhys / name: Rhys Evans (6f6c1d8, 9ee5bd0)
  • ✅ login: benjie / name: Benjie (acb8db3)
  • ✅ login: spawnia / name: Benedikt Franke (acb8db3)

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.

Excellent first step! I've fixed the syntax in the request and since it's a bit longer that the other examples I've broken it out into a code block. I've also made it clear that the example is well-formed to help readers understand the distinction. What do you think?

spec/GraphQLOverHTTP.md Outdated Show resolved Hide resolved
Co-authored-by: Benjie <benjie@jemjie.com>
@benjie
Copy link
Member

benjie commented Feb 2, 2024

Excellent; please sign the CLA so that we can accept your contribution ❤️

@benjie benjie changed the title Update GraphQLOverHTTP.md Add example of variable coercion failure Feb 12, 2024
@benjie
Copy link
Member

benjie commented Feb 12, 2024

We need to copy the RFC labels from the spec repo.

I see this as an editorial change; assuming there's no concerns raised in the next couple weeks I think we should merge it.

cc @abernix @balshor @benjie @deinok @ErikWittern @jaydenseric @michaelstaib @mike-marcacci @mmatsa @Shane32 @sjparsons @spawnia @sungam3r @Touchstone117 @enisdenjo @JoviDeCroock


```json
{
"query": "query getItem($id: String!) { item(id: $id) { id } }",
Copy link
Member

@spawnia spawnia Feb 12, 2024

Choose a reason for hiding this comment

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

Suggested change
"query": "query getItem($id: String!) { item(id: $id) { id } }",
"query": "query ItemName($id: ID!) { item(id: $id) { id name } }",

The example works fine as is. However, I think it is more common to use PascalCase for operation names, and I also think it is best practice to use the ID type for identifiers.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it is more common to use PascalCase for operation names

Perhaps; but I usually see schemas that follow this: https://www.apollographql.com/docs/technotes/TN0002-schema-naming-conventions/

I also think it is best practice to use the ID type for identifiers.

Agree

Copy link
Member

Choose a reason for hiding this comment

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

https://www.apollographql.com/docs/technotes/TN0002-schema-naming-conventions/ does not explicitly talk about operation names, but its examples do use PascalCase (query Products).

Copy link
Member

@benjie benjie Feb 12, 2024

Choose a reason for hiding this comment

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

I actually went through the spec and extracted the conventions from that; results are here:

https://benjie.dev/graphql/naming

The spec uses a mixture for operation names but camelCase is more common than UpperCamelCase. You may find the part on fragments interesting because I had a conversation with Lee about it.

Copy link
Member

Choose a reason for hiding this comment

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

I tweaked your example and committed that, I added a get prefix to match spec examples such as getDogName https://spec.graphql.org/draft/#example-069e1

Co-authored-by: Benedikt Franke <benedikt@franke.tech>
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.

None yet

6 participants