From c8c5df495dae2316f20dc81665f0cd5b21a2c8f7 Mon Sep 17 00:00:00 2001 From: Clive Wong Date: Fri, 18 Oct 2024 10:56:23 -0700 Subject: [PATCH 1/4] ESlint plugin lwc mobile md docs --- src/docs/apex-import.md | 10 +++ src/docs/no-aggregate-query-supported.md | 32 +++++++ .../no-fiscal-date-filtering-supported.md | 56 ++++++++++++ src/docs/no-more-than-1-parent-record.md | 55 ++++++++++++ src/docs/no-more-than-3-child-entities.md | 89 +++++++++++++++++++ src/docs/no-more-than-3-root-entities.md | 76 ++++++++++++++++ src/docs/no-mutation-supported.md | 46 ++++++++++ src/docs/no-semi-anti-join-supported.md | 56 ++++++++++++ src/docs/unsupported-scope.md | 25 ++++++ 9 files changed, 445 insertions(+) create mode 100644 src/docs/apex-import.md create mode 100644 src/docs/no-aggregate-query-supported.md create mode 100644 src/docs/no-fiscal-date-filtering-supported.md create mode 100644 src/docs/no-more-than-1-parent-record.md create mode 100644 src/docs/no-more-than-3-child-entities.md create mode 100644 src/docs/no-more-than-3-root-entities.md create mode 100644 src/docs/no-mutation-supported.md create mode 100644 src/docs/no-semi-anti-join-supported.md create mode 100644 src/docs/unsupported-scope.md diff --git a/src/docs/apex-import.md b/src/docs/apex-import.md new file mode 100644 index 0000000..49efcac --- /dev/null +++ b/src/docs/apex-import.md @@ -0,0 +1,10 @@ +# apex-import + +Using Apex in LWC Offline-enabled mobile apps requires additional considerations to ensure proper functioning in offline scenarios. + +When a client device is offline, Apex-based features can read data that was cached while online, but changes (writing data) can’t be saved back to the server. Nor can a change via Apex methods be enqueued as a draft into the Offline Queue. A Lightning web component that uses Apex must be prepared to handle a network connection error as a normal response, for both reading and writing operations. + +See [Use Apex While Mobile and Offline](https://developer.salesforce.com/docs/atlas.en-us.mobile_offline.meta/mobile_offline/apex.htm) for more details. + + + diff --git a/src/docs/no-aggregate-query-supported.md b/src/docs/no-aggregate-query-supported.md new file mode 100644 index 0000000..e9b198e --- /dev/null +++ b/src/docs/no-aggregate-query-supported.md @@ -0,0 +1,32 @@ +# no-aggregate-query-supported + +This rule flags the use of aggregate queries with GraphQL. Currently, aggregate queries with GraphQL are not supported for offline use cases. + +See [Feature Limitations of Offline GraphQL +](https://developer.salesforce.com/docs/atlas.en-us.mobile_offline.meta/mobile_offline/use_graphql_limitations.htm) for more details. + +## ❌ Incorrect + +```GraphQL +query AvgOpportunityExample { + uiapi { + aggregate { + Opportunity { + edges { + node { + aggregate { + Amount { + avg { + value + displayValue + } + } + } + } + } + } + } + } +} + +``` \ No newline at end of file diff --git a/src/docs/no-fiscal-date-filtering-supported.md b/src/docs/no-fiscal-date-filtering-supported.md new file mode 100644 index 0000000..234e75b --- /dev/null +++ b/src/docs/no-fiscal-date-filtering-supported.md @@ -0,0 +1,56 @@ +# no-fiscal-date-filtering-supported + +This rule flags filters that use fiscal date literals and ranges with GraphQL. Currently, filters that use fiscal date literals and ranges with GraphQL are not supported for offline use cases. + +See [Feature Limitations of Offline GraphQL +](https://developer.salesforce.com/docs/atlas.en-us.mobile_offline.meta/mobile_offline/use_graphql_limitations.htm) for more details. + +## ❌ Incorrect + +```GraphQL +{ + uiapi { + query { + Account( + where: { + LastActivityDate: { + eq: { literal: { THIS_FISCAL_YEAR } } + } + } + ) { + edges { + node { + Id + } + } + } + } + } +} + +``` + +## ✅ Correct + +```GraphQL +{ + uiapi { + query { + Account( + where: { + LastActivityDate: { + eq: { literal: { THIS_YEAR } } + } + } + ) { + edges { + node { + Id + } + } + } + } + } +} + +``` \ No newline at end of file diff --git a/src/docs/no-more-than-1-parent-record.md b/src/docs/no-more-than-1-parent-record.md new file mode 100644 index 0000000..5410006 --- /dev/null +++ b/src/docs/no-more-than-1-parent-record.md @@ -0,0 +1,55 @@ +# no-more-than-1-parent-record + +This rule flags queries that fetch child entities fetching more than 1 parent record with GraphQL. To resolve this error, set the parent's 'first' argument value to 1. + +See [Feature Limitations of Offline GraphQL +](https://developer.salesforce.com/docs/atlas.en-us.mobile_offline.meta/mobile_offline/use_graphql_limitations.htm) for more details. + +## ❌ Incorrect + +```GraphQL +query { + uiapi { + Account(first: 100) { + edges { + node { + Id + Contacts { + edges { + node { + Id + } + } + } + } + } + } + } + } + +``` + + +## ✅ Correct + +```GraphQL +query { + uiapi { + Account(first: 1) { + edges { + node { + Id + Contacts { + edges { + node { + Id + } + } + } + } + } + } + } + } + +``` \ No newline at end of file diff --git a/src/docs/no-more-than-3-child-entities.md b/src/docs/no-more-than-3-child-entities.md new file mode 100644 index 0000000..4c80f46 --- /dev/null +++ b/src/docs/no-more-than-3-child-entities.md @@ -0,0 +1,89 @@ +# no-more-than-3-child-entities + +This rule flags queries that fetch more than 3 child entities. To resolve this error, do not fetch more than 3 child entities. + +See [Feature Limitations of Offline GraphQL +](https://developer.salesforce.com/docs/atlas.en-us.mobile_offline.meta/mobile_offline/use_graphql_limitations.htm) for more details. + +## ❌ Incorrect + +```GraphQL +query { + uiapi { + Account(first: 1) { + edges { + node { + Id + Contacts { + edges { + node { + Id + } + } + } + Opportunities { + edges { + node { + Id + } + } + } + Cases { + edges { + node { + Id + } + } + } + Documents { + edges { + node { + Id + } + } + } + } + } + } + } +} + +``` + +## ✅ Correct + +```GraphQL +query { + uiapi { + Account(first: 1) { + edges { + node { + Id + Contacts { + edges { + node { + Id + } + } + } + Opportunities { + edges { + node { + Id + } + } + } + Cases { + edges { + node { + Id + } + } + } + } + } + } + } +} + +``` diff --git a/src/docs/no-more-than-3-root-entities.md b/src/docs/no-more-than-3-root-entities.md new file mode 100644 index 0000000..2c12b60 --- /dev/null +++ b/src/docs/no-more-than-3-root-entities.md @@ -0,0 +1,76 @@ +# no-more-than-3-root-entities + +This rule flags queries that fetch more than 3 root entities. To resolve this error, do not fetch more than 3 root entities. + +See [Feature Limitations of Offline GraphQL +](https://developer.salesforce.com/docs/atlas.en-us.mobile_offline.meta/mobile_offline/use_graphql_limitations.htm) for more details. + + +## ❌ Incorrect + +```GraphQL +uiapi { + query { + Contacts { + edges { + node { + Id + } + } + } + Opportunities { + edges { + node { + Id + } + } + } + Cases { + edges { + node { + Id + } + } + } + Documents { + edges { + node { + Id + } + } + } + } +} + +``` + +## ✅ Correct + +```GraphQL +uiapi { + query { + Contacts { + edges { + node { + Id + } + } + } + Opportunities { + edges { + node { + Id + } + } + } + Cases { + edges { + node { + Id + } + } + } + } +} + +``` diff --git a/src/docs/no-mutation-supported.md b/src/docs/no-mutation-supported.md new file mode 100644 index 0000000..8c6a5d5 --- /dev/null +++ b/src/docs/no-mutation-supported.md @@ -0,0 +1,46 @@ +# no-mutation-supported + +This rule flags the use of mutations (data modification) with GraphQL. Currently, mutations with GraphQL are not supported for offline use cases. + +See [Feature Limitations of Offline GraphQL +](https://developer.salesforce.com/docs/atlas.en-us.mobile_offline.meta/mobile_offline/use_graphql_limitations.htm) for more details. + +## ❌ Incorrect + +```GraphQL +mutation AccountExample { + uiapi { + AccountCreate(input: { Account: { Name: "Trailblazer Express" } }) { + Record { + Id + Name { + value + } + } + } + } +} + +``` + +## ✅ Correct + +```GraphQL +query accountQuery { + uiapi { + query { + Account { + edges { + node { + Id + Name { + value + } + } + } + } + } + } +} + +``` diff --git a/src/docs/no-semi-anti-join-supported.md b/src/docs/no-semi-anti-join-supported.md new file mode 100644 index 0000000..aef2d3f --- /dev/null +++ b/src/docs/no-semi-anti-join-supported.md @@ -0,0 +1,56 @@ +# no-semi-anti-join-supported + +This rule flags the use of semi-join and anti-join filters with GraphQL. Currently, semi-join and anti-join filters with GraphQL are not supported for offline use cases. + +See [Feature Limitations of Offline GraphQL +](https://developer.salesforce.com/docs/atlas.en-us.mobile_offline.meta/mobile_offline/use_graphql_limitations.htm) for more details. + +## ❌ Incorrect + +```GraphQL +query AccountExample { + uiapi { + query { + Account (where: { + Id: { inq: { + Opportunity: { + StageName: { eq: "Closed Won" } }, + ApiName:"AccountId" + } + } + }) { + edges { + node { + Id + Name { value } + } + } + } + } + } + } +} + +``` + +## ✅ Correct + +```GraphQL +query AccountExample { + uiapi { + query { + Account { + edges { + node { + Id + Name { + value + } + } + } + } + } + } +} + +``` diff --git a/src/docs/unsupported-scope.md b/src/docs/unsupported-scope.md new file mode 100644 index 0000000..2cf1c98 --- /dev/null +++ b/src/docs/unsupported-scope.md @@ -0,0 +1,25 @@ +# unsupoorted-scope + +This rule flags the use scopes other than "MINE" and "ASSIGNEDTOME" with GraphQL. Currently, "MINE" is supported for all entities and "ASSIGNEDTOME" is supported for ServiceAppoinment. No other scopes are supported for GraphQL offline use cases. + +See [Feature Limitations of Offline GraphQL +](https://developer.salesforce.com/docs/atlas.en-us.mobile_offline.meta/mobile_offline/use_graphql_limitations.htm) for more details. + +## ❌ Incorrect + +```GraphQL +query assignedtomeQuery { + uiapi { + query { + Case(scope: ASSIGNEDTOME) { + edges { + node { + Id + } + } + } + } + +} + +``` From 97125e3e59a658cdb3966e4896e88285ba6f55c8 Mon Sep 17 00:00:00 2001 From: Clive Wong Date: Tue, 29 Oct 2024 11:07:05 -0700 Subject: [PATCH 2/4] Update src/docs/unsupported-scope.md Co-authored-by: Kevin Hawkins --- src/docs/unsupported-scope.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/docs/unsupported-scope.md b/src/docs/unsupported-scope.md index 2cf1c98..5f20617 100644 --- a/src/docs/unsupported-scope.md +++ b/src/docs/unsupported-scope.md @@ -1,4 +1,4 @@ -# unsupoorted-scope +# unsupported-scope This rule flags the use scopes other than "MINE" and "ASSIGNEDTOME" with GraphQL. Currently, "MINE" is supported for all entities and "ASSIGNEDTOME" is supported for ServiceAppoinment. No other scopes are supported for GraphQL offline use cases. From d0218081abe5d6c625a8caf2e31399c713ab4083 Mon Sep 17 00:00:00 2001 From: Clive Wong Date: Tue, 29 Oct 2024 11:07:15 -0700 Subject: [PATCH 3/4] Update src/docs/unsupported-scope.md Co-authored-by: Kevin Hawkins --- src/docs/unsupported-scope.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/docs/unsupported-scope.md b/src/docs/unsupported-scope.md index 5f20617..02e6202 100644 --- a/src/docs/unsupported-scope.md +++ b/src/docs/unsupported-scope.md @@ -1,6 +1,6 @@ # unsupported-scope -This rule flags the use scopes other than "MINE" and "ASSIGNEDTOME" with GraphQL. Currently, "MINE" is supported for all entities and "ASSIGNEDTOME" is supported for ServiceAppoinment. No other scopes are supported for GraphQL offline use cases. +This rule flags the use of scopes other than "MINE" and "ASSIGNEDTOME" with GraphQL. Currently, "MINE" is supported for all entities and "ASSIGNEDTOME" is supported for ServiceAppoinment. No other scopes are supported for GraphQL offline use cases. See [Feature Limitations of Offline GraphQL ](https://developer.salesforce.com/docs/atlas.en-us.mobile_offline.meta/mobile_offline/use_graphql_limitations.htm) for more details. From 4358f29af04a8f27412dfbb565bc040cf6ee49de Mon Sep 17 00:00:00 2001 From: Clive Wong Date: Tue, 29 Oct 2024 11:18:57 -0700 Subject: [PATCH 4/4] Update src/docs/no-more-than-1-parent-record.md Co-authored-by: Kevin Hawkins --- src/docs/no-more-than-1-parent-record.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/docs/no-more-than-1-parent-record.md b/src/docs/no-more-than-1-parent-record.md index 5410006..843b12f 100644 --- a/src/docs/no-more-than-1-parent-record.md +++ b/src/docs/no-more-than-1-parent-record.md @@ -1,6 +1,6 @@ # no-more-than-1-parent-record -This rule flags queries that fetch child entities fetching more than 1 parent record with GraphQL. To resolve this error, set the parent's 'first' argument value to 1. +For GraphQL queries containing parent records with child entities, Offline GraphQL does not support retrieving more than one parent record using the 'first' argument. To resolve this error, set the parent's 'first' argument value to 1. See [Feature Limitations of Offline GraphQL ](https://developer.salesforce.com/docs/atlas.en-us.mobile_offline.meta/mobile_offline/use_graphql_limitations.htm) for more details.