Sha256: 2be26e85244bb2832ad80bdc6038805d6f6cb71094c626f01cba8684365badca

Contents?: true

Size: 986 Bytes

Versions: 147

Compression:

Stored size: 986 Bytes

Contents

# frozen_string_literal: true
module GraphQL
  module StaticValidation
    module FieldsAreDefinedOnType
      def on_field(node, parent)
        parent_type = @object_types[-2]
        field = context.warden.get_field(parent_type, node.name)

        if field.nil?
          if parent_type.kind.union?
            add_error(GraphQL::StaticValidation::FieldsHaveAppropriateSelectionsError.new(
              "Selections can't be made directly on unions (see selections on #{parent_type.graphql_name})",
              nodes: parent,
              node_name: parent_type.graphql_name
            ))
          else
            add_error(GraphQL::StaticValidation::FieldsAreDefinedOnTypeError.new(
              "Field '#{node.name}' doesn't exist on type '#{parent_type.graphql_name}'",
              nodes: node,
              field: node.name,
              type: parent_type.graphql_name
            ))
          end
        else
          super
        end
      end
    end
  end
end

Version data entries

147 entries across 147 versions & 2 rubygems

Version Path
graphql-2.2.16 lib/graphql/static_validation/rules/fields_are_defined_on_type.rb
graphql-2.1.13 lib/graphql/static_validation/rules/fields_are_defined_on_type.rb
graphql-2.3.7 lib/graphql/static_validation/rules/fields_are_defined_on_type.rb
graphql-2.3.6 lib/graphql/static_validation/rules/fields_are_defined_on_type.rb
graphql-2.3.5 lib/graphql/static_validation/rules/fields_are_defined_on_type.rb
graphql-2.0.31 lib/graphql/static_validation/rules/fields_are_defined_on_type.rb
graphql-2.3.2 lib/graphql/static_validation/rules/fields_are_defined_on_type.rb
graphql-2.3.1 lib/graphql/static_validation/rules/fields_are_defined_on_type.rb
graphql-1.13.23 lib/graphql/static_validation/rules/fields_are_defined_on_type.rb
graphql-2.3.0 lib/graphql/static_validation/rules/fields_are_defined_on_type.rb
graphql-2.2.14 lib/graphql/static_validation/rules/fields_are_defined_on_type.rb
graphql-2.2.13 lib/graphql/static_validation/rules/fields_are_defined_on_type.rb
graphql-2.2.12 lib/graphql/static_validation/rules/fields_are_defined_on_type.rb
graphql-2.0.29 lib/graphql/static_validation/rules/fields_are_defined_on_type.rb
graphql-2.1.12 lib/graphql/static_validation/rules/fields_are_defined_on_type.rb
graphql-1.13.22 lib/graphql/static_validation/rules/fields_are_defined_on_type.rb
graphql-2.2.11 lib/graphql/static_validation/rules/fields_are_defined_on_type.rb
graphql-2.2.10 lib/graphql/static_validation/rules/fields_are_defined_on_type.rb
graphql-2.2.9 lib/graphql/static_validation/rules/fields_are_defined_on_type.rb
graphql-2.2.8 lib/graphql/static_validation/rules/fields_are_defined_on_type.rb