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

Simple type validation in QueryFragment derive. #3

Merged
merged 1 commit into from
Feb 9, 2020
Merged

Conversation

obmarg
Copy link
Owner

@obmarg obmarg commented Feb 9, 2020

When writing QueryFragments, it's really easy to get confused about
what GraphQL types are required, what are lists etc. When you get this
wrong, the Rust compile errors are either not as helpful as they could
be or plain confusing.

This updates the QueryFragment derive code to be a bit smarter here: it
will specifically check for the cases where there's a mismatch in list
types or optionalness.

I've also updated it to error when people provide generic types in their
structs. Currently this will cause a syntax error in the derive output,
with an unhelpful message, so I'm just explicitly disallowing it for
now. Can revisit fixing the underlying error at some point.

When writing QueryFragments, it's really easy to get confused about
what GraphQL types are required, what are lists etc.  When you get this
wrong, the Rust compile errors are either not as helpful as they could
be _or_ plain confusing.

This updates the QueryFragment derive code to be a bit smarter here: it
will specifically check for the cases where there's a mismatch in list
types or optionalness.

I've also updated it to error when people provide generic types in their
structs.  Currently this will cause a syntax error in the derive output,
with an unhelpful message, so I'm just explicitly disallowing it for
now.  Can revisit fixing the underlying error at some point.
@obmarg obmarg merged commit 28cf876 into master Feb 9, 2020
@obmarg obmarg deleted the type-validation branch February 9, 2020 16:19
obmarg added a commit that referenced this pull request Feb 9, 2020
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.

1 participant