Sha256: dee565ab1626be4d9037f22e26cba06b25b6a38f40dfcee88b36b7538419fffd

Contents?: true

Size: 723 Bytes

Versions: 1

Compression:

Stored size: 723 Bytes

Contents

# frozen_string_literal: true
module GraphQL
  module StaticValidation
    module VariablesAreInputTypes
      def on_variable_definition(node, parent)
        type_name = get_type_name(node.type)
        type = context.warden.get_type(type_name)

        if type.nil?
          add_error("#{type_name} isn't a defined input type (on $#{node.name})", node)
        elsif !type.kind.input?
          add_error("#{type.name} isn't a valid input type (on $#{node.name})", node)
        end

        super
      end

      private

      def get_type_name(ast_type)
        if ast_type.respond_to?(:of_type)
          get_type_name(ast_type.of_type)
        else
          ast_type.name
        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/variables_are_input_types.rb