Sha256: fe011fb2a9ed364f6bae035b29a9efdccda68b9159ff71154df1a29e6248e87e

Contents?: true

Size: 607 Bytes

Versions: 8

Compression:

Stored size: 607 Bytes

Contents

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

8 entries across 8 versions & 1 rubygems

Version Path
graphql-0.19.3 lib/graphql/static_validation/rules/mutation_root_exists.rb
graphql-0.19.2 lib/graphql/static_validation/rules/mutation_root_exists.rb
graphql-0.19.1 lib/graphql/static_validation/rules/mutation_root_exists.rb
graphql-0.19.0 lib/graphql/static_validation/rules/mutation_root_exists.rb
graphql-0.18.15 lib/graphql/static_validation/rules/mutation_root_exists.rb
graphql-0.18.14 lib/graphql/static_validation/rules/mutation_root_exists.rb
graphql-0.18.13 lib/graphql/static_validation/rules/mutation_root_exists.rb
graphql-0.18.12 lib/graphql/static_validation/rules/mutation_root_exists.rb