Module: GraphQL::StaticValidation::MutationRootExists

Defined in:
lib/graphql/static_validation/rules/mutation_root_exists.rb

Instance Method Summary collapse

Instance Method Details

#on_operation_definition(node, _parent) ⇒ Object



5
6
7
8
9
10
11
12
13
14
# File 'lib/graphql/static_validation/rules/mutation_root_exists.rb', line 5

def on_operation_definition(node, _parent)
  if node.operation_type == 'mutation' && context.query.types.mutation_root.nil?
    add_error(GraphQL::StaticValidation::MutationRootExistsError.new(
      'Schema is not configured for mutations',
      nodes: node
    ))
  else
    super
  end
end