Skip to content

Commit 783bd23

Browse files
authored
Merge pull request #70 from clivewong/main
W-16028081 ESLint plugin lwc mobile repo docs
2 parents 940ecbf + 4358f29 commit 783bd23

9 files changed

+445
-0
lines changed

src/docs/apex-import.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# apex-import
2+
3+
Using Apex in LWC Offline-enabled mobile apps requires additional considerations to ensure proper functioning in offline scenarios.
4+
5+
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.
6+
7+
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.
8+
9+
10+
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# no-aggregate-query-supported
2+
3+
This rule flags the use of aggregate queries with GraphQL. Currently, aggregate queries with GraphQL are not supported for offline use cases.
4+
5+
See [Feature Limitations of Offline GraphQL
6+
](https://developer.salesforce.com/docs/atlas.en-us.mobile_offline.meta/mobile_offline/use_graphql_limitations.htm) for more details.
7+
8+
## ❌ Incorrect
9+
10+
```GraphQL
11+
query AvgOpportunityExample {
12+
uiapi {
13+
aggregate {
14+
Opportunity {
15+
edges {
16+
node {
17+
aggregate {
18+
Amount {
19+
avg {
20+
value
21+
displayValue
22+
}
23+
}
24+
}
25+
}
26+
}
27+
}
28+
}
29+
}
30+
}
31+
32+
```
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# no-fiscal-date-filtering-supported
2+
3+
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.
4+
5+
See [Feature Limitations of Offline GraphQL
6+
](https://developer.salesforce.com/docs/atlas.en-us.mobile_offline.meta/mobile_offline/use_graphql_limitations.htm) for more details.
7+
8+
## ❌ Incorrect
9+
10+
```GraphQL
11+
{
12+
uiapi {
13+
query {
14+
Account(
15+
where: {
16+
LastActivityDate: {
17+
eq: { literal: { THIS_FISCAL_YEAR } }
18+
}
19+
}
20+
) {
21+
edges {
22+
node {
23+
Id
24+
}
25+
}
26+
}
27+
}
28+
}
29+
}
30+
31+
```
32+
33+
## ✅ Correct
34+
35+
```GraphQL
36+
{
37+
uiapi {
38+
query {
39+
Account(
40+
where: {
41+
LastActivityDate: {
42+
eq: { literal: { THIS_YEAR } }
43+
}
44+
}
45+
) {
46+
edges {
47+
node {
48+
Id
49+
}
50+
}
51+
}
52+
}
53+
}
54+
}
55+
56+
```
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# no-more-than-1-parent-record
2+
3+
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.
4+
5+
See [Feature Limitations of Offline GraphQL
6+
](https://developer.salesforce.com/docs/atlas.en-us.mobile_offline.meta/mobile_offline/use_graphql_limitations.htm) for more details.
7+
8+
## ❌ Incorrect
9+
10+
```GraphQL
11+
query {
12+
uiapi {
13+
Account(first: 100) {
14+
edges {
15+
node {
16+
Id
17+
Contacts {
18+
edges {
19+
node {
20+
Id
21+
}
22+
}
23+
}
24+
}
25+
}
26+
}
27+
}
28+
}
29+
30+
```
31+
32+
33+
## ✅ Correct
34+
35+
```GraphQL
36+
query {
37+
uiapi {
38+
Account(first: 1) {
39+
edges {
40+
node {
41+
Id
42+
Contacts {
43+
edges {
44+
node {
45+
Id
46+
}
47+
}
48+
}
49+
}
50+
}
51+
}
52+
}
53+
}
54+
55+
```
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# no-more-than-3-child-entities
2+
3+
This rule flags queries that fetch more than 3 child entities. To resolve this error, do not fetch more than 3 child entities.
4+
5+
See [Feature Limitations of Offline GraphQL
6+
](https://developer.salesforce.com/docs/atlas.en-us.mobile_offline.meta/mobile_offline/use_graphql_limitations.htm) for more details.
7+
8+
## ❌ Incorrect
9+
10+
```GraphQL
11+
query {
12+
uiapi {
13+
Account(first: 1) {
14+
edges {
15+
node {
16+
Id
17+
Contacts {
18+
edges {
19+
node {
20+
Id
21+
}
22+
}
23+
}
24+
Opportunities {
25+
edges {
26+
node {
27+
Id
28+
}
29+
}
30+
}
31+
Cases {
32+
edges {
33+
node {
34+
Id
35+
}
36+
}
37+
}
38+
Documents {
39+
edges {
40+
node {
41+
Id
42+
}
43+
}
44+
}
45+
}
46+
}
47+
}
48+
}
49+
}
50+
51+
```
52+
53+
## ✅ Correct
54+
55+
```GraphQL
56+
query {
57+
uiapi {
58+
Account(first: 1) {
59+
edges {
60+
node {
61+
Id
62+
Contacts {
63+
edges {
64+
node {
65+
Id
66+
}
67+
}
68+
}
69+
Opportunities {
70+
edges {
71+
node {
72+
Id
73+
}
74+
}
75+
}
76+
Cases {
77+
edges {
78+
node {
79+
Id
80+
}
81+
}
82+
}
83+
}
84+
}
85+
}
86+
}
87+
}
88+
89+
```
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# no-more-than-3-root-entities
2+
3+
This rule flags queries that fetch more than 3 root entities. To resolve this error, do not fetch more than 3 root entities.
4+
5+
See [Feature Limitations of Offline GraphQL
6+
](https://developer.salesforce.com/docs/atlas.en-us.mobile_offline.meta/mobile_offline/use_graphql_limitations.htm) for more details.
7+
8+
9+
## ❌ Incorrect
10+
11+
```GraphQL
12+
uiapi {
13+
query {
14+
Contacts {
15+
edges {
16+
node {
17+
Id
18+
}
19+
}
20+
}
21+
Opportunities {
22+
edges {
23+
node {
24+
Id
25+
}
26+
}
27+
}
28+
Cases {
29+
edges {
30+
node {
31+
Id
32+
}
33+
}
34+
}
35+
Documents {
36+
edges {
37+
node {
38+
Id
39+
}
40+
}
41+
}
42+
}
43+
}
44+
45+
```
46+
47+
## ✅ Correct
48+
49+
```GraphQL
50+
uiapi {
51+
query {
52+
Contacts {
53+
edges {
54+
node {
55+
Id
56+
}
57+
}
58+
}
59+
Opportunities {
60+
edges {
61+
node {
62+
Id
63+
}
64+
}
65+
}
66+
Cases {
67+
edges {
68+
node {
69+
Id
70+
}
71+
}
72+
}
73+
}
74+
}
75+
76+
```

src/docs/no-mutation-supported.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# no-mutation-supported
2+
3+
This rule flags the use of mutations (data modification) with GraphQL. Currently, mutations with GraphQL are not supported for offline use cases.
4+
5+
See [Feature Limitations of Offline GraphQL
6+
](https://developer.salesforce.com/docs/atlas.en-us.mobile_offline.meta/mobile_offline/use_graphql_limitations.htm) for more details.
7+
8+
## ❌ Incorrect
9+
10+
```GraphQL
11+
mutation AccountExample {
12+
uiapi {
13+
AccountCreate(input: { Account: { Name: "Trailblazer Express" } }) {
14+
Record {
15+
Id
16+
Name {
17+
value
18+
}
19+
}
20+
}
21+
}
22+
}
23+
24+
```
25+
26+
## ✅ Correct
27+
28+
```GraphQL
29+
query accountQuery {
30+
uiapi {
31+
query {
32+
Account {
33+
edges {
34+
node {
35+
Id
36+
Name {
37+
value
38+
}
39+
}
40+
}
41+
}
42+
}
43+
}
44+
}
45+
46+
```

0 commit comments

Comments
 (0)