Docs
Launch GraphOS Studio

GraphOS schema linter rules

Reference


This reference lists the rules that you can enforce with GraphOS schema linting, along with the code that returns for each rule violation.

Rules are categorized by the part(s) of your that they correspond to.

Schema

DOES_NOT_PARSE

The linter raises this violation if it attempts to read a malformed GraphQL . Check your for any syntax errors.


QUERY_DOCUMENT_DECLARATION

A GraphQL should never include definitions of GraphQL operations (such as queries and s).

schema.graphql
type Query {
users: [User!]!
}
query GetUsers { # Don't define operations in a schema document
users {
id
}
}

All fields

FIELD_NAMES_SHOULD_BE_CAMEL_CASE

names should always use camelCase.

schema.graphql
type User {
FirstName: String! # PascalCase
}

schema.graphql
type User {
firstName: String # camelCase
}

RESTY_FIELD_NAMES

A 's name should never start with any of the following verbs:

  • get
  • list
  • post
  • put
  • patch

Most s should not start with any verb, with the exception of Mutation s. For Mutation s, use a verb that more specifically describes the action being performed (such as create, delete, or edit).

schema.graphql
type Query {
getUsers: [User!]!
}

schema.graphql
type Query {
users: [User!]!
}

All types

These rules apply to all types that appear in a GraphQL , including:

  • Objects
  • Interfaces
  • Inputs
  • Enums
  • Unions

TYPE_NAMES_SHOULD_BE_PASCAL_CASE

All type names should use PascalCase.

schema.graphql
type streamingService { # camelCase
id: ID!
}

schema.graphql
type StreamingService { # PascalCase
id: ID!
}

TYPE_PREFIX

Type names should never use the prefix Type.

schema.graphql
type TypeBook {
title: String!
}

schema.graphql
type Book {
title: String!
}

TYPE_SUFFIX

Type names should never use the suffix Type.

schema.graphql
type BookType {
title: String!
}

schema.graphql
type Book {
title: String!
}

Objects

OBJECT_PREFIX

An 's name should never use the prefix Object.

schema.graphql
type ObjectBook {
title: String!
}

schema.graphql
type Book {
title: String!
}

OBJECT_SUFFIX

An 's name should never use the suffix Object.

schema.graphql
type BookObject {
title: String!
}

schema.graphql
type Book {
title: String!
}

Interfaces

INTERFACE_PREFIX

An interface type's name should never use the prefix Interface.

schema.graphql
interface InterfaceBook {
title: String
author: String
}

schema.graphql
interface Book {
title: String
author: String
}

INTERFACE_SUFFIX

An interface type's name should never use the suffix Interface.

schema.graphql
interface BookInterface {
title: String
author: String
}

schema.graphql
interface Book {
title: String
author: String
}

Inputs & arguments

INPUT_ARGUMENT_NAMES_SHOULD_BE_CAMEL_CASE

A GraphQL 's name should always use camelCase.

schema.graphql
type Mutation {
createBlogPost(BlogPostContent: BlogPostContent!): Post # PascalCase
}

schema.graphql
type Mutation {
createBlogPost(blogPostContent: BlogPostContent!): Post # camelCase
}

INPUT_TYPE_SUFFIX

An input type's name should always use the suffix Input.

schema.graphql
input BlogPostDetails {
title: String!
content: String!
}

schema.graphql
input BlogPostDetailsInput {
title: String!
content: String!
}

Enums

ENUM_VALUES_SHOULD_BE_SCREAMING_SNAKE_CASE

Enum values should always use SCREAMING_SNAKE_CASE.

schema.graphql
enum Amenity {
public_park # snake_case
}

schema.graphql
enum Amenity {
PUBLIC_PARK # SCREAMING_SNAKE_CASE 😱
}

ENUM_PREFIX

An enum type's name should never use the prefix Enum.

schema.graphql
enum EnumResidence {
HOUSE
APARTMENT
CONDO
}

schema.graphql
enum Residence {
HOUSE
APARTMENT
CONDO
}

ENUM_SUFFIX

An enum type's name should never use the suffix Enum.

schema.graphql
enum ResidenceEnum {
HOUSE
APARTMENT
CONDO
}

schema.graphql
enum Residence {
HOUSE
APARTMENT
CONDO
}

ENUM_USED_AS_INPUT_WITHOUT_SUFFIX

If an enum type is used as an input , its name should use the suffix Input.

schema.graphql
enum Role {
EDITOR
VIEWER
}
type Query {
users(role: Role): [User!]!
}

schema.graphql
enum RoleInput {
EDITOR
VIEWER
}
type Query {
users(role: RoleInput): [User!]!
}

ENUM_USED_AS_OUTPUT_DESPITE_SUFFIX

If an enum is used as the return type of a non-input , its name should not use the suffix Input.

schema.graphql
enum RoleInput {
EDITOR
VIEWER
}
type Query {
userRole(userId: ID!): RoleInput
}

schema.graphql
enum Role {
EDITOR
VIEWER
}
type Query {
userRole(userId: ID!): Role
}

Directives

DIRECTIVE_NAMES_SHOULD_BE_CAMEL_CASE

names should always use camelCase.

schema.graphql
directive @SpecialField on FIELD_DEFINITION # PascalCase

schema.graphql
directive @specialField on FIELD_DEFINITION # camelCase

CONTACT_DIRECTIVE_MISSING

A should always provide owner contact details via the @contact . Learn more.

schema.graphql
directive @contact(
"Contact title of the subgraph owner"
name: String!
"URL where the subgraph's owner can be reached"
url: String
"Other relevant notes can be included here; supports markdown links"
description: String
) on SCHEMA
extend schema @contact(
name: "Products Team",
url: "https://myteam.slack.com/archives/teams-chat-room-url",
description: "Send urgent issues to [#oncall](https://yourteam.slack.com/archives/oncall)."
)

DEPRECATED_DIRECTIVE_MISSING_REASON

The @deprecated should always include a reason .

schema.graphql
type Product {
title: String @deprecated
name: String!
}

schema.graphql
type Product {
title: String @deprecated(reason: "Use Product.name instead")
name: String!
}

TAG_DIRECTIVE_USES_UNKNOWN_NAME

The @tag should always use an approved value for its name . You specify approved values in GraphOS Studio.

Previous
Schema linting
Next
Connecting to GitHub
Edit on GitHubEditForumsDiscord