Sha256: d7522f34bb765502ab86f032288d4fadf36b9aa64a9c8ca68c1243e9e349f74c

Contents?: true

Size: 636 Bytes

Versions: 2

Compression:

Stored size: 636 Bytes

Contents

# frozen_string_literal: true
module GraphQL
  module StaticValidation
    class MutationRootExists
      include GraphQL::StaticValidation::Message::MessageHelper

      def validate(context)
        return if context.schema.mutation

        visitor = context.visitor

        visitor[GraphQL::Language::Nodes::OperationDefinition].enter << ->(ast_node, prev_ast_node) {
          if ast_node.operation_type == 'mutation'
            context.errors << message('Schema is not configured for mutations', ast_node, context: context)
            return GraphQL::Language::Visitor::SKIP
          end
        }
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
graphql-1.4.0 lib/graphql/static_validation/rules/mutation_root_exists.rb
graphql-1.3.0 lib/graphql/static_validation/rules/mutation_root_exists.rb