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

Schema Parsing Fails with "" is not a valid identifier on empty names #252

Closed
adimit opened this issue Jun 5, 2021 · 3 comments · Fixed by #253
Closed

Schema Parsing Fails with "" is not a valid identifier on empty names #252

adimit opened this issue Jun 5, 2021 · 3 comments · Fixed by #253
Labels
🐞 bug Something isn't working

Comments

@adimit
Copy link

adimit commented Jun 5, 2021

The following declaration causes an error in proc macro expansion when using use_schema!():

type Foo {
  _: Boolean
}

The error is:

message: `""` is not a valid identifier

This is a common workaround to represent empty types and should probably be supported.

@adimit adimit changed the title Schema Parsing Fails with "" is not a valid identifier Schema Parsing Fails with "" is not a valid identifier on empty names Jun 5, 2021
@obmarg
Copy link
Owner

obmarg commented Jun 6, 2021

Hi @adimit, thanks for the report - I didn’t realise this was a common pattern (although it makes sense - I have usually just used a named field to simulate an empty type, but this is a little more obvious)

This seems to be a bug in the “to_snake_case” method we’re using. Got a fix ready for that, although it’s not all that needs done unfortunately - underscore isn’t a valid rust identifier so will need to figure out a way to support it in the various places it appears in the cynic output

@obmarg obmarg added the 🐞 bug Something isn't working label Jun 6, 2021
obmarg added a commit that referenced this issue Jun 6, 2021
#### Why are we making this change?

As reported in #252 - it's a common pattern to name a field with an underscore
when you have an otherwise empty type (as empty types are not supported in
graphql).  Cynic does not support this (nor does rust).

#### What effects does this change have?

Adds support for underscore fields in schemas, and adds renames to the query
fragment derive so that you can work around rusts lack of support for `_`
fields.

Fixes #252 
Does part of #151
@obmarg
Copy link
Owner

obmarg commented Jun 6, 2021

Fix for this is now released in v0.14.0

@adimit
Copy link
Author

adimit commented Jun 7, 2021

Cool, that's great. Thanks for the quick fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants