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

Code Style Guidelines for GraphQL #269

Open
buskamuza opened this issue Sep 10, 2019 · 4 comments
Open

Code Style Guidelines for GraphQL #269

buskamuza opened this issue Sep 10, 2019 · 4 comments
Assignees

Comments

@buskamuza
Copy link
Contributor

Document code style guidelines for GraphQL schema.
Currently, the following unwritten agreements exist:

  1. quantity should be used, not qty
  2. Camel case SHOULD be used for queries and mutations (root-level fields)
  3. Camel case SHOULD be used for arguments
    3.1. Investigate if Snake case should be used (in case it's already more widely used than Camel case)
  4. Upper camel case SHOULD be used for types
  5. Snake case SHOULD be used for fields
  • Investigate if the above rules make sense or other agreements should be introduced. Document the agreements as guidelines.
  • Investigate if any other code style guidelines make sense and document them.
@jednano
Copy link
Contributor

jednano commented Sep 10, 2019

  1. I agree that we shouldn't be shortening names.
  2. Agreed.
  3. Not sure what else there is to investigate. The GraphQL docs themselves use camel case arguments, which is consistent with everything else.
  4. Agreed.
  5. Again. GraphQL docs use camel case everywhere for fields. I think anything else would be considered bad practice.

The most common consumer of a GraphQL API is a browser (i.e., JavaScript). As such, we should conform to JavaScript's patterns and use camel case throughout.

  • JavaScript clients shouldn't have to change the case into something else in order to have consistent casing in their applications
    • Any such conversions cause overhead in the client, which is unacceptable.
    • A non-native function is required to perform such conversions, which adds additional footprint to the JavaScript payload.

@buskamuza
Copy link
Contributor Author

What do we do with EAV attributes - they are snake case?

  • Convert them for consistency

@orlangur
Copy link
Contributor

@buskamuza 2-5 why SHOULD and not MUST?

@stijnbernards
Copy link
Member

  1. I agree that we shouldn't be shortening names.
  2. Agreed.
  3. Not sure what else there is to investigate. The GraphQL docs themselves use camel case arguments, which is consistent with everything else.
  4. Agreed.
  5. Again. GraphQL docs use camel case everywhere for fields. I think anything else would be considered bad practice.

The most common consumer of a GraphQL API is a browser (i.e., JavaScript). As such, we should conform to JavaScript's patterns and use camel case throughout.

  • JavaScript clients shouldn't have to change the case into something else in order to have consistent casing in their applications

    • Any such conversions cause overhead in the client, which is unacceptable.
    • A non-native function is required to perform such conversions, which adds additional footprint to the JavaScript payload.

I Agree with you on 3 and 5 GraphQL response fields must be camelCased.

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

No branches or pull requests

6 participants