Sha256: 9d5b3fd4a289c14b96b6a1eb9f1f9f56d4c7ddb8738599ef84bb26881ba250e9

Contents?: true

Size: 614 Bytes

Versions: 1

Compression:

Stored size: 614 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("Selections can't be made directly on unions (see selections on #{parent_type.name})", parent)
          else
            add_error("Field '#{node.name}' doesn't exist on type '#{parent_type.name}'", node)
          end
        else
          super
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
graphql-1.9.0.pre1 lib/graphql/static_validation/rules/fields_are_defined_on_type.rb