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

Field name clash with Elm reserved words #40

Closed
madsflensted opened this issue Feb 9, 2018 · 2 comments
Closed

Field name clash with Elm reserved words #40

madsflensted opened this issue Feb 9, 2018 · 2 comments
Labels

Comments

@madsflensted
Copy link

I have a simple schema with this object definition

type Service {
  name : String
  port :  Int
}

This causes graphqelm to throw an error, which actually seems to come from elm-format. The error message is formated weird so I won't paste it here.

Looking at the generated code (and the elm-format error) it was clear that port can not be used as a field name. I expect the same will be true for other words like module and import.

This is not a big problem, so this issue is more to see if it was possible to catch this naming clash with relevant reserved words in Elm and display a better error message.

@dillonkearns
Copy link
Owner

Hello @madsflensted, thank you for reporting the issue! Yes, I’m handling the reserved word type right now but for some reason I forgot to add others! The normalization code should be handling this. The strategy I’m using is to just add a trailing _, so in this case the field would be called port_. I won’t be at a computer for a couple of weeks, but I’ll make this change as soon as I’m back home! Here’s the relevant file: https://github.com/dillonkearns/graphqelm/blob/a9bbff3d18968684d9a968f32983ce837ec8c449/src/Graphqelm/Generator/Normalize.elm#L9.

@dillonkearns
Copy link
Owner

Resolved by #41, now fixed in npm version 3.1.8!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants