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

Utf8GraphQLRequestParser.Parse improve error message if OperationName is empty #7664

Open
mrange opened this issue Oct 31, 2024 · 0 comments
Assignees
Milestone

Comments

@mrange
Copy link

mrange commented Oct 31, 2024

Product

Hot Chocolate

Is your feature request related to a problem?

Hello,

First, I want to express my appreciation for the excellent work you've done with HotChocolate. It has been a reliable tool for parsing GraphQL in our projects.

Recently, while troubleshooting an error encountered by one of our integration partners, I noticed something that may be worth looking into. The error message was as follows: Expected a 'Colon'-token, but found a 'String'-token. At first glance, I assumed there might be an issue with the GraphQL code provided by our partner. However, it took some time to reproduce and identify the source of the problem.

Upon investigation, I discovered that the error occurs when the operationName is left empty in a request. Here's an example of the failing request:

{
  "operationName": "",
  "variables": {},
  "query": "query GetAssignmentPage {\r\n    assignments {\r\n        items {\r\n            assignmentId\r\n        }\r\n    }\r\n}"
}

In contrast, the following request succeeds:

{
  "operationName": "X",
  "variables": {},
  "query": "query GetAssignmentPage {\r\n    assignments {\r\n        items {\r\n            assignmentId\r\n        }\r\n    }\r\n}"
}

While I understand that operationName should probably not be empty, the error message initially misled me, leading to several hours of troubleshooting before pinpointing the issue. I've advised our partner to always provide a valid operationName, and we've resolved our issue.

I wanted to bring this to your attention in case it's an area that could be improved or clarified in future updates. Thank you for your continued support and dedication to improving HotChocolate!

The solution you'd like

The error message if OperationName is empty is changed to something like:

OperationName must not be empty

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

3 participants