What role does lightning/uiObjectInfoApi play in fetching object metadata and picklist values?
Answer
Basics: Instead of hard-coding labels or picklist options, an LWC can ask the platform at runtime. getObjectInfo returns the object's labels, fields (with data types, labels, createable and updateable flags), child relationships, record type infos and the defaultRecordTypeId. getPicklistValues returns the values for one picklist field for a given record type.
How it works: Import the adapter and field references from @salesforce/schema, then wire. First wire getObjectInfo to obtain defaultRecordTypeId (or take a record's recordTypeId), then wire getPicklistValues with recordTypeId and fieldApiName. The result contains values (each with label, value) and, for dependent picklists, controllerValues and per-value validFor indexes.
Advanced / deep dive: Responses are filtered by the user's access, so they reflect FLS and record type availability, which is the main advantage over hard-coding or Apex describe. They are cached and shared through LDS, reducing server calls, and wire adapters re-provision when reactive parameters change. For many objects use getObjectInfos (plural). getPicklistValuesByRecordType returns all picklists for a record type in one call, efficient for forms. Dependent picklists: filter values by validFor.includes(controllerValues[selectedControllerValue]). For the Master record type (no record types defined) use the id 012000000000000AAA. These adapters give metadata only, not records; combine with lightning/uiRecordApi (getRecord, createRecord, ) for data. Alternatives: with handles picklists automatically; Apex is heavier and not cached the same way; the newer GraphQL wire adapter is another data path. In offline mobile, metadata must be primed or cached.