Sha256: 78da59b40d67eef8fb82fa736178bb000bfd5b327723198170785578673ea713

Contents?: true

Size: 663 Bytes

Versions: 73

Compression:

Stored size: 663 Bytes

Contents

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

      def validate(context)
        return if context.warden.root_type_for_operation("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

73 entries across 73 versions & 1 rubygems

Version Path
graphql-1.8.18 lib/graphql/static_validation/rules/mutation_root_exists.rb
graphql-1.8.17 lib/graphql/static_validation/rules/mutation_root_exists.rb
graphql-1.8.16 lib/graphql/static_validation/rules/mutation_root_exists.rb
graphql-1.8.15 lib/graphql/static_validation/rules/mutation_root_exists.rb
graphql-1.8.14 lib/graphql/static_validation/rules/mutation_root_exists.rb
graphql-1.8.13 lib/graphql/static_validation/rules/mutation_root_exists.rb
graphql-1.8.12 lib/graphql/static_validation/rules/mutation_root_exists.rb
graphql-1.8.11 lib/graphql/static_validation/rules/mutation_root_exists.rb
graphql-1.8.10 lib/graphql/static_validation/rules/mutation_root_exists.rb
graphql-1.8.9 lib/graphql/static_validation/rules/mutation_root_exists.rb
graphql-1.8.8 lib/graphql/static_validation/rules/mutation_root_exists.rb
graphql-1.8.7 lib/graphql/static_validation/rules/mutation_root_exists.rb
graphql-1.8.6 lib/graphql/static_validation/rules/mutation_root_exists.rb
graphql-1.8.5 lib/graphql/static_validation/rules/mutation_root_exists.rb
graphql-1.8.4 lib/graphql/static_validation/rules/mutation_root_exists.rb
graphql-1.8.3 lib/graphql/static_validation/rules/mutation_root_exists.rb
graphql-1.8.2 lib/graphql/static_validation/rules/mutation_root_exists.rb
graphql-1.8.1 lib/graphql/static_validation/rules/mutation_root_exists.rb
graphql-1.8.0 lib/graphql/static_validation/rules/mutation_root_exists.rb
graphql-1.8.0.pre11 lib/graphql/static_validation/rules/mutation_root_exists.rb