Skip to main content

Naming Convention

These rules enforce naming conventions.
Field names should always use camelCase.
Violation
type User {
  First_Name: String
}
Correct:
Correct
type User {
  firstName: String
}
Type names should always use PascalCase.
Violation
type userProject {
  id: ID!
}
Correct
type UserProject {
  id: ID!
}
A type’s name should never be prefixed with ‘Type’.
Violation
type TypeUser {
  id: ID!
}
Correct
type User {
  id: ID!
}
A type’s name should never be suffixed with ‘Type’.
Violation
type UserType {
  id: ID!
}
Correct
type User {
  id: ID!
}
An input’s name should never be prefixed with ‘Input’.
Violation
input InputUser {
  id: ID!
}
Correct
input UserInput {
  id: ID!
}
An input’s name should always be suffixed with ‘Input’.
Violation
input User {
  id: ID!
}
Correct
input UserInput {
  id: ID!
}
An enum’s name should never be prefixed with ‘Enum’.
Violation
enum EnumUserStatus {
  ADMIN
  USER
}
Correct
enum UserStatus {
  ADMIN
  USER
}
An enum’s name should never be suffixed with ‘Enum’.
Violation
enum UserStatusEnum {
  ADMIN
  USER
}
Correct
enum UserStatus {
  ADMIN
  USER
}
An interface type’s name should never be prefixed with ‘Interface’.
Violation
interface InterfaceUser {
  id: ID!
}
Correct
interface User {
  id: ID!
}
An interface type’s name should never be suffixed with ‘Interface’.
Violation
interface UserInterface {
  id: ID!
}
Correct
interface User {
  id: ID!
}
Enum values should always use UPPER_CASE.
Violation
enum UserRole {
  admin
  user
}
Correct
enum UserRole {
  ADMIN
  USER
}

Alphabetical Sort

These rules enforce the arrangement of types, fields and so on in the schema.
Ensures all fields are sorted in alphabetical order.
Violation
type User {
  lastName: String
  firstName: String
}
Correct
type User {
  firstName: String
  lastName: String
}
Ensures all enum values are sorted in alphabetical order.
Violation
enum UserRole {
  USER
  ADMIN
}
Correct
enum UserRole {
  ADMIN
  USER
}
Ensures all definitions are sorted in alphabetical order.Violation:
Violation
type User{
  id: ID;
  name: String;
}

type Member {
  id: ID;
  name: String;
}
Correct:
Correct
type Member {
  id: ID;
  name: String;
}

type User{
  id: ID;
  name: String;
}

Others

Ensures all type definitions are accompanied by a description.The types include:-
  • ObjectTypeDefinition
  • InterfaceTypeDefinition
  • EnumTypeDefinition
  • ScalarTypeDefinition
  • InputObjectTypeDefinition
  • UnionTypeDefinition
Violation
type User {
  id: ID!
}

interface Member {
  id: ID!
}
Correct
# Represents a user in the system
type User {
  id: ID!
}

# Represents a member in the system
interface Member {
  id: ID!
}
Ensures enum values eliminate duplicates by disallowing case insensitivity.
Violation
enum UserRole {
  ADMIN
  admin
}
Correct
enum UserRole {
  ADMIN
}
Ensures field names do not include their type’s name as a prefix.
Violation
type User {
  userId: ID!
}
Correct
type User {
  id: ID!
}
Requires providing a reason for the @deprecated directive.
Violation
type User {
  id: ID! @deprecated
}
Correct
type User {
  id: ID! @deprecated(reason: "No longer in use")
}
Requires providing a deletion date for the @deprecated directive.
Violation
type User {
  id: ID! @deprecated(reason: "No longer in use")
}
Correct
type User {
  id: ID! @deprecated(reason: "No longer in use", date: "2023-01-01")
}
I