-
Catches errors automatically:
ActiveRecord::RecordNotFound
-
Includes
raise_errorresponse handler inGraphQL::Schema::RelayClassicMutationraise_error person.errors.full_messages.to_sentence unless person.update(status: :active)
-
Add
authorizeoption 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
preloadwhich 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