Skip to content

Commit

Permalink
Merge pull request #70 from clivewong/main
Browse files Browse the repository at this point in the history
W-16028081 ESLint plugin lwc mobile repo docs
  • Loading branch information
sfdctaka authored Nov 12, 2024
2 parents 940ecbf + 4358f29 commit 783bd23
Show file tree
Hide file tree
Showing 9 changed files with 445 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/docs/apex-import.md
Original file line number Diff line number Diff line change
@@ -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.



32 changes: 32 additions & 0 deletions src/docs/no-aggregate-query-supported.md
Original file line number Diff line number Diff line change
@@ -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
}
}
}
}
}
}
}
}
}

```
56 changes: 56 additions & 0 deletions src/docs/no-fiscal-date-filtering-supported.md
Original file line number Diff line number Diff line change
@@ -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
}
}
}
}
}
}

```
55 changes: 55 additions & 0 deletions src/docs/no-more-than-1-parent-record.md
Original file line number Diff line number Diff line change
@@ -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
}
}
}
}
}
}
}
}

```
89 changes: 89 additions & 0 deletions src/docs/no-more-than-3-child-entities.md
Original file line number Diff line number Diff line change
@@ -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
}
}
}
}
}
}
}
}

```
76 changes: 76 additions & 0 deletions src/docs/no-more-than-3-root-entities.md
Original file line number Diff line number Diff line change
@@ -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
}
}
}
}
}

```
46 changes: 46 additions & 0 deletions src/docs/no-mutation-supported.md
Original file line number Diff line number Diff line change
@@ -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
}
}
}
}
}
}
}

```
Loading

0 comments on commit 783bd23

Please sign in to comment.