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..843b12f --- /dev/null +++ b/src/docs/no-more-than-1-parent-record.md @@ -0,0 +1,55 @@ +# no-more-than-1-parent-record + +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. + +## ❌ 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..02e6202 --- /dev/null +++ b/src/docs/unsupported-scope.md @@ -0,0 +1,25 @@ +# unsupported-scope + +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. + +## ❌ Incorrect + +```GraphQL +query assignedtomeQuery { + uiapi { + query { + Case(scope: ASSIGNEDTOME) { + edges { + node { + Id + } + } + } + } + +} + +```