Apr 8, 2022 8:18 AM
GraphQL naming conventions
The GraphQL specification is flexible and doesn’t impose specific naming guidelines. However, it’s helpful to establish a set of conventions to ensure consistency across your organization. We recommend the following:
- Field names should use
- Type names should use
ConversationParticipant. This matches how classes are defined in the languages mentioned above.
- Enum names should use
- Enum values should use
ALL_CAPSbecause they are similar to constants. If you are using
kebab-casein the queries then, you can easily translate them using the provided ruby method.
- Folder and file names are lower case.
- File names include the name of the component the file represents. Plurals are used in folder names, but not in file names.
- Don’t prefix the files of subfolders with anything because they already live under the them and naming it like
company_mutation.rbwould be redundant and wouldn’t matter.
- Mutation should start with an action they are trying to perform, like,
- Queries should describe what you are looking for, like,
def to_kebab return self.downcase.dasherize end
Folder and file structure
/controllers /jobs /models /channels /graphql /queries /user_profile.rb /mutations /company.rb