-
Includes
enum
shorthand,field :status, enum("PersonStatusEnum", Person.statuses.keys), null: false
-
Catches errors automatically:
ActiveRecord::RecordNotFound
-
Includes
raise_error
response handler inGraphQL::Schema::RelayClassicMutation
raise_error person.errors.full_messages.to_sentence unless person.update(status: :active)
-
Add
authorize
option tofield
# app/graphql/types/base_field.rb field_class.include(Phantom::Graphql::FieldExtensions)
field :posts, [Types::PostType], authorize: "PostPolicy#index?", null: false
-
Pass asscoation name in
preload
which will fix N+1 query -
Pass Policy name in
scope
, which will reduces scope in preloaded queryclass Types::PostType < Types::BaseObject field :comments, [Types::CommentType], scope: "CommentPolicy", preload: :comments, null: false end