Skip to content

Commit

Permalink
Merge pull request salesforce#83 from akong-sf/prefetch_issue
Browse files Browse the repository at this point in the history
Fix prefetch issue while priming
  • Loading branch information
dbreese authored Jan 31, 2024
2 parents dadcb8d + 8a14ca8 commit 24a1195
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 5 additions & 1 deletion docs/RelatedRecords.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

[The LWC related records example](../force-app/main/default/lwc/accountRelatedContacts) demonstrates the capability to view related records, for example `Contacts`, from an object, for example `Account`, using GraphQL queries. When a user's mobile device is online and priming the briefcase, the related records are prefetched and stored in the cache and can be viewed in offline mode.

There’s a known issue that [GraphQL query prefetches fail](https://issues.salesforce.com/issue/a028c00000xGGwEAAW/graphql-query-fails-prefetch-with-an-unknown-field-warning), and as a result the `accountRelatedContacts` LWC won’t work offline. A fix for this known issue is coming soon. In the meantime, see this [Knowledge Article](https://help.salesforce.com/s/articleView?language=en_US&id=000396405&type=1) for a resolution to this known issue.
> **Note**
> There’s a known issue that [GraphQL query prefetches fail](https://issues.salesforce.com/issue/a028c00000xGGwEAAW/graphql-query-fails-prefetch-with-an-unknown-field-warning), and as a result the `accountRelatedContacts` LWC won’t work offline. In the meantime, see this [Knowledge Article](https://help.salesforce.com/s/articleView?language=en_US&id=000396405&type=1) for a resolution to this known issue.
> **Update**
> As of Spring '24 release the issue has been addressed.
In this example, we perform a GraphQL query to fetch related `Contacts` from an `Account` record.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@ export default class AccountRelatedContacts extends NavigationMixin(
/*
There is a currently Known Issue {@link https://issues.salesforce.com/issue/a028c00000xGGwE/graphql-query-fails-prefetch-with-an-unknown-field-warning} with GraphQL wire adapters where this will cause the component to fail to load offline.
There is a workaround that can be implemented in this Knowledge Article {@link https://help.salesforce.com/s/articleView?language=en_US&id=000396405&type=1}.
As of Spring '24 release the issue has been addressed.
*/
get accountQuery() {
if (!this.recordId) return undefined;

return gql`
query accountWithChildContacts($recordId: ID) {
uiapi {
Expand Down Expand Up @@ -67,7 +66,7 @@ export default class AccountRelatedContacts extends NavigationMixin(

get graphqlVariables() {
return {
recordId: this.recordId,
recordId: this.recordId || "",
};
}

Expand Down

0 comments on commit 24a1195

Please sign in to comment.