class GraphQL::Schema::Mutation


GRAPHQL
}
}
}
}
login
author {
body
comment {
errors
createComment(postId: “1”, body: “Nice Post!”) {
mutation {
result = MySchema.execute <<-GRAPHQL
# Call it from GraphQL:
end
field :create_comment, mutation: Mutations::CreateComment
class Types::Mutation < GraphQL::Schema::Object
# Hook it up to your mutation:
end
end
end
}
errors: comment.errors.full_messages
comment: nil,
{
# Failed save, return the errors to the client
else
}
errors: [],
comment: comment,
{
# Successful creation, return the created object with no errors
if comment.save
comment = post.comments.build(body: body, author: context)
post = Post.find(post_id)
def resolve(body:, post_id:)
field :errors, [String], null: false
field :comment, Types::Comment, null: true
argument :post_id, ID, required: true
argument :body, String, required: true
class Mutations::CreateComment < GraphQL::Schema::Mutation
# Define the mutation:
@example Creating a comment
@see {GraphQL::Schema::RelayClassicMutation} for an extension of this class with some conventions built-in.
override the various ‘generate_*` methods.
If you want to customize how this class generates types, in your base class,
then it can be hooked up to your mutation root object type.
This base class accepts configuration for a mutation root field,

def call_resolve(_args_hash)

Other tags:
    Api: - private
def call_resolve(_args_hash)
  # Clear any cached values from `loads` or authorization:
  dataloader.clear_cache
  super
end

def conflict_field_name_warning(field_defn)

def conflict_field_name_warning(field_defn)
  "#{self.graphql_name}'s `field :#{field_defn.name}` conflicts with a built-in method, use `hash_key:` or `method:` to pick a different resolve behavior for this field (for example, `hash_key: :#{field_defn.resolver_method}_value`, and modify the return hash). Or use `method_conflict_warning: false` to suppress this warning."
end

def generate_payload_type

Override this to attach self as `mutation`
def generate_payload_type
  payload_class = super
  payload_class.mutation(self)
  payload_class
end

def visible?(context)

def visible?(context)
  true
end