Table of Contents

Recommendations

Here you will find all the recommendations for making best of this gem.

Important In the future, items from this list may become RuboCop cops.
This section is under construction.

General

  1. Never reference a type by their class!
  2. Always provide a type for fields and arguments, even if it will be resolved properly to :id or :string;
  3. Use symbol names for scalars and string gql names for anything else;
  4. Do not set arguments using the arguments named argument. Open a block and set them up inside of it instead;
  5. Do not define fields on the schema. Use alternatives instead;
  6. Provide description for everything, either directly or using I18n;
  7. Do not use fields chaining definition;
  8. Avoid using inline types, except for unions and enums;

Types

  1. If a type requires nested fields to be fully qualified, then don’t create a scalar;
  2. Always assign a type to a class by its name, not its constant value;
  3. Register all database aliases on the Type Map to avoid warnings;

Request

  1. Never load data during the resolve stage!
  2. Use the prepare event stage of requests to load data;

Callbacks

  1. Prefer using current.something or current_value.something than just calling something. You may get some unexpected results.