The lookupValues field of LookupValues type provides lookup search for Salesforce lookup and relationship fields. The GraphQL lookup values feature mirrors the UI API Get Lookup Field Suggestions With POST resource. The response includes matching records and display metadata for lookup target object types. This feature supports type-ahead search, recent lookups, and full search capabilities.
Pass in lookupValues in the uiapi field. For example, use objectApiName: "Opportunity" and fieldApiName: "AccountId" to return lookup values for the account lookup field on the opportunity object.
objectApiName - The object API name of a supported object. This argument is required.
fieldApiName - The API name of the lookup or reference field on the object. This argument is required.
q - Search query string for filtering lookup results. This argument is required with TYPE_AHEAD and SEARCH search types.
searchType - Search strategy that the LookupSearchType enum provides. Default value is RECENT.
targetApiName - For polymorphic lookup fields, filters results to a specific target object type.
sourceRecord - A RecordSnapshotInput type with the record’s live, possibly unsaved, field values for filtered lookups that depend on other field values on the source record. This argument must contain only one top-level key and it must use the ObjectApiName, for example, Opportunity: OpportunitySnapshotFields.
LookupValues Type
The LookupValues type returns matching records and display metadata for a single lookup target object type.
first - Number of records per page. Default value is 10.
after - Returns the results after the given cursor.
orderBy - A RecordLookupOrderBy type that accepts one field per target object, named after the object’s search type, such as OpportunitySearch. This argument isn’t supported for recent or type-ahead search types.
secondaryField - API name of the secondary field to display alongside the primary name field.
suggestionsInfo - Display layout and matching field configuration for lookup suggestions.
advancedDisplayFields - Column configuration for the Advanced Lookup modal.
RecordLookupConnection Type
The RecordLookupConnection type represents a result set of lookup records that ties together the records and page info.
The RecordLookupPayload type contains these fields.
Record - A RecordSearch record matching the lookup query.
SecondaryFieldValue - Value of the secondary display field for this record.
RecordSearch Interface
The RecordSearch interface is a marker interface for search record results. Field types are limited to those returnable by the search RETURNING clause.
RECENT - Returns most recently used records for the lookup field in order of recency and doesn’t support custom ordering.
TYPE_AHEAD - Returns records matching the query string for type-ahead suggestions in order of relevance and doesn’t support custom ordering or after cursor ordering.
SEARCH - Performs a full search across the target object.