Naming types differ from naming fields.
- type blogPost { # bad
- type Blog_Post { # also bad
+ type BlogPost { # good
title: String!
}
GraphQL comes with built-in scalar types: String
, Int
, Boolean
, Float
. All of them are named using UpperCamelCase
.
Internal GraphQL Introspection Types such as __Type
, __Field
, __InputValue
also follow this convention with 2 underscores at the beginning.
A lot of projects are using the statically typed nature of GraphQL to generate internal type definitions, many of whom use it for static analysis. Both Flowtype and TypeScript use UpperCamelCase
to name complex types.
According to Wikipedia, we should use UpperCamelCase
in JavaScript, Java, Swift, and Kotlin for classes and type declarations.
This rule can be validated using graphql-eslint
, read more about naming-convention
rule.