When would you choose the GraphQL wire adapter over Lightning Data Service/UI API or Apex for an LWC, and how would you refresh the data after a mutation?
Strong Interview Answer
Use the GraphQL wire adapter when the required Salesforce data can be expressed by the supported GraphQL schema and a flexible related-data graph is best retrieved reactively in one request. For standard record CRUD, LDS/UI API is usually simpler; use Apex when custom server-side logic or unsupported data access is required. Treat wired GraphQL data as immutable and use `refreshGraphQL()` with the wired result when that GraphQL data must be refreshed.
What to Listen For
- GraphQL for supported graph-shaped reactive reads
- LDS/UI API for standard record operations
- Apex for custom server logic
- wired data treated as immutable
- `refreshGraphQL()` rather than `refreshApex()`
Caution
Do not answer 'GraphQL is always simpler.' The correct choice depends on whether the supported schema satisfies the data requirement.