Sha256: f4962b98b9f9c5d3695fcf1596aa4d45400f6be243e0ca83fe7454db8815b6f6

Contents?: true

Size: 1.45 KB

Versions: 191

Compression:

Stored size: 1.45 KB

Contents

# frozen_string_literal: true
module GraphQL
  module StaticValidation
    module NoDefinitionsArePresent
      include GraphQL::StaticValidation::Error::ErrorHelper

      def initialize(*)
        super
        @schema_definition_nodes = []
      end

      def on_invalid_node(node, parent)
        @schema_definition_nodes << node
        nil
      end

      alias :on_directive_definition :on_invalid_node
      alias :on_schema_definition :on_invalid_node
      alias :on_scalar_type_definition :on_invalid_node
      alias :on_object_type_definition :on_invalid_node
      alias :on_input_object_type_definition :on_invalid_node
      alias :on_interface_type_definition :on_invalid_node
      alias :on_union_type_definition :on_invalid_node
      alias :on_enum_type_definition :on_invalid_node
      alias :on_schema_extension :on_invalid_node
      alias :on_scalar_type_extension :on_invalid_node
      alias :on_object_type_extension :on_invalid_node
      alias :on_input_object_type_extension :on_invalid_node
      alias :on_interface_type_extension :on_invalid_node
      alias :on_union_type_extension :on_invalid_node
      alias :on_enum_type_extension :on_invalid_node

      def on_document(node, parent)
        super
        if @schema_definition_nodes.any?
          add_error(GraphQL::StaticValidation::NoDefinitionsArePresentError.new(%|Query cannot contain schema definitions|, nodes: @schema_definition_nodes))
        end
      end
    end
  end
end

Version data entries

191 entries across 191 versions & 2 rubygems

Version Path
graphql-2.4.4 lib/graphql/static_validation/rules/no_definitions_are_present.rb
graphql-2.4.3 lib/graphql/static_validation/rules/no_definitions_are_present.rb
graphql-2.4.2 lib/graphql/static_validation/rules/no_definitions_are_present.rb
graphql-2.4.1 lib/graphql/static_validation/rules/no_definitions_are_present.rb
graphql-2.4.0 lib/graphql/static_validation/rules/no_definitions_are_present.rb
graphql-2.3.20 lib/graphql/static_validation/rules/no_definitions_are_present.rb
graphql-2.3.19 lib/graphql/static_validation/rules/no_definitions_are_present.rb
graphql-2.3.18 lib/graphql/static_validation/rules/no_definitions_are_present.rb
graphql-2.3.17 lib/graphql/static_validation/rules/no_definitions_are_present.rb
graphql-2.3.16 lib/graphql/static_validation/rules/no_definitions_are_present.rb
graphql-2.3.15 lib/graphql/static_validation/rules/no_definitions_are_present.rb
graphql-2.3.14 lib/graphql/static_validation/rules/no_definitions_are_present.rb
graphql-2.3.13 lib/graphql/static_validation/rules/no_definitions_are_present.rb
graphql-2.3.12 lib/graphql/static_validation/rules/no_definitions_are_present.rb
graphql-2.3.11 lib/graphql/static_validation/rules/no_definitions_are_present.rb
graphql-2.3.10 lib/graphql/static_validation/rules/no_definitions_are_present.rb
graphql-2.2.16 lib/graphql/static_validation/rules/no_definitions_are_present.rb
graphql-2.1.13 lib/graphql/static_validation/rules/no_definitions_are_present.rb
graphql-2.3.9 lib/graphql/static_validation/rules/no_definitions_are_present.rb
graphql-2.3.8 lib/graphql/static_validation/rules/no_definitions_are_present.rb