# frozen_string_literal: truerequire"graphql/relay/type_extensions"moduleGraphQL# The parent for all type classes.classBaseTypeincludeGraphQL::Define::NonNullWithBangincludeGraphQL::Define::InstanceDefinableincludeGraphQL::Relay::TypeExtensionsaccepts_definitions:name,:description,:introspection,:default_scalar,:default_relay,{connection: GraphQL::Define::AssignConnection,global_id_field: GraphQL::Define::AssignGlobalIdField,}ensure_defined(:graphql_name,:name,:description,:introspection?,:default_scalar?)attr_accessor:ast_nodedefinitialize@introspection=false@default_scalar=false@default_relay=falseenddefinitialize_copy(other)super# Reset these derived defaults@connection_type=nil@edge_type=nilend# @return [String] the name of this type, must be unique within a Schemaattr_reader:name# Future-compatible alias# @see {GraphQL::SchemaMember}alias:graphql_name:name# Future-compatible alias# @see {GraphQL::SchemaMember}alias:graphql_definition:itselfdefname=(name)GraphQL::NameValidator.validate!(name)@name=nameend# @return [String, nil] a description for this typeattr_accessor:description# @return [Boolean] Is this type a predefined introspection type?defintrospection?@introspectionend# @return [Boolean] Is this type a built-in scalar type? (eg, `String`, `Int`)defdefault_scalar?@default_scalarend# @return [Boolean] Is this type a built-in Relay type? (`Node`, `PageInfo`)defdefault_relay?@default_relayend# @api privateattr_writer:introspection,:default_scalar,:default_relay# @param other [GraphQL::BaseType] compare to this object# @return [Boolean] are these types equivalent? (incl. non-null, list)# @see {ModifiesAnotherType#==} for override on List & NonNull typesdef==(other)other.is_a?(GraphQL::BaseType)&&self.name==other.nameend# If this type is modifying an underlying type,# return the underlying type. (Otherwise, return `self`.)defunwrapselfend# @return [GraphQL::NonNullType] a non-null version of this typedefto_non_null_typeGraphQL::NonNullType.new(of_type: self)end# @return [GraphQL::ListType] a list version of this typedefto_list_typeGraphQL::ListType.new(of_type: self)endmoduleModifiesAnotherTypedefunwrapself.of_type.unwrapenddef==(other)other.is_a?(ModifiesAnotherType)&&other.of_type==of_typeendend# Find out which possible type to use for `value`.# Returns self if there are no possible types (ie, not Union or Interface)defresolve_type(value,ctx)selfend# Print the human-readable name of this type using the query-string naming patterndefto_snameendalias:inspect:to_salias:to_type_signature:to_sdefvalid_isolated_input?(value)valid_input?(value,GraphQL::Query::NullContext)enddefvalidate_isolated_input(value)validate_input(value,GraphQL::Query::NullContext)enddefcoerce_isolated_input(value)coerce_input(value,GraphQL::Query::NullContext)enddefcoerce_isolated_result(value)coerce_result(value,GraphQL::Query::NullContext)enddefvalid_input?(value,ctx=nil)ifctx.nil?warn_deprecated_coerce("valid_isolated_input?")ctx=GraphQL::Query::NullContextendvalidate_input(value,ctx).valid?enddefvalidate_input(value,ctx=nil)ifctx.nil?warn_deprecated_coerce("validate_isolated_input")ctx=GraphQL::Query::NullContextendifvalue.nil?GraphQL::Query::InputValidationResult.newelsevalidate_non_null_input(value,ctx)endenddefcoerce_input(value,ctx=nil)ifvalue.nil?nilelseifctx.nil?warn_deprecated_coerce("coerce_isolated_input")ctx=GraphQL::Query::NullContextendcoerce_non_null_input(value,ctx)endenddefcoerce_result(value,ctx)raiseGraphQL::RequiredImplementationMissingErrorend# Types with fields may override this# @param name [String] field name to lookup for this type# @return [GraphQL::Field, nil]defget_field(name)nilend# During schema definition, types can be defined inside procs or as strings.# This function converts it to a type instance# @return [GraphQL::BaseType]defself.resolve_related_type(type_arg)casetype_argwhenProc# lazy-eval it, then try againresolve_related_type(type_arg.call)whenString# Get a constant by this nameresolve_related_type(Object.const_get(type_arg))elseiftype_arg.respond_to?(:graphql_definition)type_arg.graphql_definitionelsetype_argendendend# Return a GraphQL string for the type definition# @param schema [GraphQL::Schema]# @param printer [GraphQL::Schema::Printer]# @see {GraphQL::Schema::Printer#initialize for additional options}# @return [String] type definitiondefto_definition(schema,printer: nil,**args)printer||=GraphQL::Schema::Printer.new(schema,**args)printer.print_type(self)end# Returns true if this is a non-nullable type. A nullable list of non-nullables is considered nullable.defnon_null?falseend# Returns true if this is a list type. A non-nullable list is considered a list.deflist?falseendprivatedefwarn_deprecated_coerce(alt_method_name)warn("Coercing without a context is deprecated; use `#{alt_method_name}` if you don't want context-awareness")endendend