Method: GraphQL::Schema::Field#connection?

Defined in:
lib/graphql/schema/field.rb

#connection?Boolean

Can be set with connection: true|false or inferred from a type name ending in *Connection

Returns:

  • (Boolean)

    if true, this field will be wrapped with Relay connection behavior



114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# File 'lib/graphql/schema/field.rb', line 114

def connection?
  if @connection.nil?
    # Provide default based on type name
    return_type_name = if @return_type_expr
      Member::BuildType.to_type_name(@return_type_expr)
    elsif @resolver_class && @resolver_class.type
      Member::BuildType.to_type_name(@resolver_class.type)
    elsif type
      # As a last ditch, try to force loading the return type:
      type.unwrap.name
    end
    if return_type_name
      @connection = return_type_name.end_with?("Connection") && return_type_name != "Connection"
    else
      # TODO set this when type is set by method
      false # not loaded yet?
    end
  else
    @connection
  end
end