class GraphQL::Schema::Validation

the object until an error is returned.
looked up for given types (by class ancestry), then applied to
Its {RULES} contain objects that respond to ‘#call(type)`. Rules are
This module provides a function for validating GraphQL types.

def self.validate(object)

Returns:
  • (String, Nil) - error message, if there was one

Parameters:
  • object (Object) -- something to be validated
def self.validate(object)
  rules = RULES.reduce([]) do |memo, (parent_class, validations)|
    memo + (object.is_a?(parent_class) ? validations : [])
  end
  # Stops after the first error
  rules.reduce(nil) { |memo, rule| memo || rule.call(object) }
end