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
- Never reference a type by their class!
- Always provide a type for fields and arguments, even if it will be resolved properly to
:id
or:string
; - Use symbol names for scalars and string gql names for anything else;
- Do not set arguments using the
arguments
named argument. Open a block and set them up inside of it instead; - Do not define fields on the schema. Use alternatives instead;
- Provide description for everything, either directly or using
I18n
; - Do not use fields chaining definition;
- Avoid using inline types, except for unions and enums;
Types
- If a type requires nested fields to be fully qualified, then don’t create a scalar;
- Always assign a type to a class by its name, not its constant value;
- Register all database aliases on the Type Map to avoid warnings;
Request
- Never load data during the resolve stage!
- Use the
prepare
event stage of requests to load data;
Callbacks
- Prefer using
current.something
orcurrent_value.something
than just callingsomething
. You may get some unexpected results.