Understand Salesforce GraphQL Implementations
Feature Limitations of Offline GraphQL
Best Practices for Using GraphQL in LWC Offline
Use Third-Party JavaScript in an LWC Offline-Enabled Component
Previous Versions
Offline GraphQL uses the same wire adapter mechanism as the standard (online only) LWC wire adapter for GraphQL. You don’t change any code to use Offline GraphQL, and your component can be used while online and offline.
While using different code isn’t necessary, you must restrict the GraphQL features that you use in your queries. The Offline GraphQL wire adapter supports a subset of the features supported by the standard LWC wire adapter.
To use Offline GraphQL, import the lightning/uiGraphQLApi module in your JavaScript file. Newer features, such as optional fields and dynamic query construction, are not supported. The lightning/graphql module doesn’t currently support offline use cases.
This subset grows in every release. A delay is typical in new features, and some features can’t be supported while disconnected from Salesforce service.
Note
Let’s get to the largest disappointments first. These major features don’t work while offline.
These major features are partially supported.
⚠️ Pagination
Where these features are required for your component or app to function, you must build them yourself, or use other data access mechanisms besides GraphQL.
For “normal” data access, read-only queries that retrieve record data, most features are supported. These features are supported, but with some limitations.
Most scalar field operators are supported.
and, not, and or are supported when the nested predicates (subclauses) use supported features.✅ DisplayValue for records and displayValue for fields are both supported.
✅ first argument to limit query result size is supported.
first isn’t a pagination feature, it’s often used with pagination features that aren’t supported.⚠️ scope argument:
MINE is supported for all entities.ASSIGNEDTOME is supported for ServiceAppointment.✅ orderBy
✅ Relationships and related record access:
first argument. To resolve this error, set the parent’s first argument value to 1.These features aren’t supported at this time.
Account.ShippingAddress aren’t supported in selections, predicates, or orderBy clauses.inq and ninq aren’t supported.in and nin operators aren’t supported for Date and Date/Time fields.Necessary object metadata, such as custom objects, fields, and layouts, is automatically loaded and cached during priming and online activity. With GraphQL, you can manually query for metadata when the occasion calls for it. When offline, there are some limitations.
getObjectInfo wire adapter. Sometimes they’re not perfectly in sync.Record query pagination:
after argument to paginate results is supported on top-level record queries. However, the after argument to paginate results for nested child relationship queries isn’t supported.⚠️ GraphQL query performance can be suboptimal on complex queries that filter or order by non-indexed fields.
⚠️ Queries that reference offline-created (draft) records in the predicate, directly in the query or indirectly through variables, return locally cached results only. The query doesn’t make a network request to the server.
Metaschema directives in GraphQL queries were deprecated in Summer ’23. However, if your GraphQL query fails prefetch in the Salesforce mobile app, Salesforce Field Service, or Mobile Offline, you must continue to use metaschema directives in your GraphQL query for referential integrity and offline priming functionality. See Known Issue: GraphQL query fails prefetch with an “Unknown Field” warning.
Important
See Also