When to Use GraphQL Wire Adapter
The GraphQL wire adapter provides numerous game changing benefits, such as a single endpoint with data aggregation across multiple resources. It speeds up your UI development for working with Salesforce data and it's a great tool for these popular use cases.
- Optimize your apps by minimizing the number of requests that's needed to fetch specific data for users with bandwidth and speed constraints.
- Your Lightning web components can query exact objects and fields without any redundant data, making your app transactions lightweight and performant.
- Pagination with cursor and offset information enables you to query and present your data with ease and efficiency, especially when working with large data sets.
LWC provides several other ways to work with Salesforce records, such as the Lightning Data Service (LDS) wire adapters,
lightning-*-form base components, and Apex.
The LDS adapters in the
lightning/ui*Api module provide the only way to create, edit, or delete records. You can work with multiple records using multiple functions where each operation is an independent transaction. Using LDS wire adapters can require multiple round trips to the server and a combination of several wire adapters to request your data.
Other adapters in the
lightning/ui*Api module provide the ability to retrieve record data if you know the Ids of the records. When these adapters perform the function you need, they are more efficient than the GraphQL wire adapter. They cannot, however, express the complex filtering, sorting, and relationship traversals that are possible with a single GraphQL query.
Apex is helpful if your object isn't supported by UI API or if you want to run an operation in system context without user permissions, sharing rules, or field-level security. You can use Apex to work with multiple records in a single transaction.