Sha256: 1b4b05b80d84d146520ae690dce8e4abf2af20f7db4d2279fa685b04d9e99f53
Contents?: true
Size: 1.57 KB
Versions: 6
Compression:
Stored size: 1.57 KB
Contents
# frozen_string_literal: true module GraphQL class Schema class Member module HasValidators include Schema::FindInheritedValue::EmptyObjects # Build {GraphQL::Schema::Validator}s based on the given configuration # and use them for this schema member # @param validation_config [Hash{Symbol => Hash}] # @return [void] def validates(validation_config) new_validators = GraphQL::Schema::Validator.from_config(self, validation_config) @own_validators ||= [] @own_validators.concat(new_validators) nil end # @return [Array<GraphQL::Schema::Validator>] def validators @own_validators || EMPTY_ARRAY end module ClassConfigured def inherited(child_cls) super child_cls.extend(ClassValidators) end module ClassValidators include Schema::FindInheritedValue::EmptyObjects def validators inherited_validators = superclass.validators if inherited_validators.any? if @own_validators.nil? inherited_validators else inherited_validators + @own_validators end elsif @own_validators.nil? EMPTY_ARRAY else @own_validators end end end end def self.extended(child_cls) super child_cls.extend(ClassConfigured) end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems