GraphQL API Wire Adapter

Fetch data using the GraphQL API wire adapter for LWC, which comes with client-side caching and data management capabilities.

lightning/graphql (v2) supersedes the lightning/uiGraphQLApi (v1) module. Here are several differences between the modules:

  • lightning/graphql provides newer features, such as optional fields and dynamic query construction.
  • lightning/graphql enables you to trigger a refresh of the query results by calling the refresh method on the emitted data.
  • lightning/uiGraphQLApi supports Mobile Offline use cases, but lightning/graphql doesn’t.
  • lightning/uiGraphQLApi enables you to trigger a refresh of the query results by calling the refreshGraphQL(result) function.

The terms v2 and v1 are annotations that are used only in documentation to highlight the difference and recency of the modules.

This table compares the GraphQL API wire adapters and the features they support.

GraphQL API Wire Adapter Featurelightning/uiGraphQLApi (v1)lightning/graphql (v2)
Mobile OfflineYes
Standard GraphQL API featuresYesYes
Optional fieldsYes
Dynamic query constructionYes

For usage details, see these references.

See Also