@salesforce/webapp-template-feature-graphql-experimental 1.35.1 → 1.36.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +52 -65
- package/package.json +6 -43
- package/rules/graphql-data-access-rule.md +5 -5
- package/skills/graphql-data-access/SKILL.md +17 -40
- package/skills/graphql-data-access/docs/explore-schema.md +3 -3
- package/dist/.a4drules/build-validation.md +0 -81
- package/dist/.a4drules/code-quality.md +0 -150
- package/dist/.a4drules/graphql/tools/knowledge/lds-explore-graphql-schema.md +0 -227
- package/dist/.a4drules/graphql/tools/knowledge/lds-generate-graphql-mutationquery.md +0 -212
- package/dist/.a4drules/graphql/tools/knowledge/lds-generate-graphql-readquery.md +0 -185
- package/dist/.a4drules/graphql/tools/knowledge/lds-guide-graphql.md +0 -205
- package/dist/.a4drules/graphql/tools/schemas/shared.graphqls +0 -1150
- package/dist/.a4drules/graphql.md +0 -408
- package/dist/.a4drules/images.md +0 -13
- package/dist/.a4drules/react.md +0 -361
- package/dist/.a4drules/react_image_processing.md +0 -45
- package/dist/.a4drules/skills/install-feature/SKILL.md +0 -67
- package/dist/.a4drules/skills/install-feature/scripts/copy-feature-assets.sh +0 -36
- package/dist/.a4drules/typescript.md +0 -224
- package/dist/.forceignore +0 -15
- package/dist/.husky/pre-commit +0 -4
- package/dist/.prettierignore +0 -11
- package/dist/.prettierrc +0 -17
- package/dist/CHANGELOG.md +0 -487
- package/dist/README.md +0 -18
- package/dist/config/project-scratch-def.json +0 -13
- package/dist/force-app/main/default/webapplications/feature-graphql/.graphqlrc.yml +0 -6
- package/dist/force-app/main/default/webapplications/feature-graphql/.prettierignore +0 -9
- package/dist/force-app/main/default/webapplications/feature-graphql/.prettierrc +0 -11
- package/dist/force-app/main/default/webapplications/feature-graphql/build/vite.config.d.ts +0 -2
- package/dist/force-app/main/default/webapplications/feature-graphql/build/vite.config.js +0 -76
- package/dist/force-app/main/default/webapplications/feature-graphql/e2e/app.spec.ts +0 -24
- package/dist/force-app/main/default/webapplications/feature-graphql/eslint.config.js +0 -113
- package/dist/force-app/main/default/webapplications/feature-graphql/feature-graphql.webapplication-meta.xml +0 -7
- package/dist/force-app/main/default/webapplications/feature-graphql/index.html +0 -13
- package/dist/force-app/main/default/webapplications/feature-graphql/package-lock.json +0 -11134
- package/dist/force-app/main/default/webapplications/feature-graphql/package.json +0 -52
- package/dist/force-app/main/default/webapplications/feature-graphql/playwright.config.ts +0 -24
- package/dist/force-app/main/default/webapplications/feature-graphql/scripts/rewrite-e2e-assets.mjs +0 -23
- package/dist/force-app/main/default/webapplications/feature-graphql/src/api/graphql-operations-types.ts +0 -118
- package/dist/force-app/main/default/webapplications/feature-graphql/src/api/graphql.test.ts +0 -91
- package/dist/force-app/main/default/webapplications/feature-graphql/src/api/graphql.ts +0 -35
- package/dist/force-app/main/default/webapplications/feature-graphql/src/api/utils/accounts.ts +0 -35
- package/dist/force-app/main/default/webapplications/feature-graphql/src/api/utils/query/highRevenueAccountsQuery.graphql +0 -29
- package/dist/force-app/main/default/webapplications/feature-graphql/src/api/utils/user.test.ts +0 -129
- package/dist/force-app/main/default/webapplications/feature-graphql/src/api/utils/user.ts +0 -53
- package/dist/force-app/main/default/webapplications/feature-graphql/src/app.tsx +0 -22
- package/dist/force-app/main/default/webapplications/feature-graphql/src/appLayout.tsx +0 -11
- package/dist/force-app/main/default/webapplications/feature-graphql/src/assets/icons/book.svg +0 -3
- package/dist/force-app/main/default/webapplications/feature-graphql/src/assets/icons/copy.svg +0 -4
- package/dist/force-app/main/default/webapplications/feature-graphql/src/assets/icons/rocket.svg +0 -3
- package/dist/force-app/main/default/webapplications/feature-graphql/src/assets/icons/star.svg +0 -3
- package/dist/force-app/main/default/webapplications/feature-graphql/src/assets/images/codey-1.png +0 -0
- package/dist/force-app/main/default/webapplications/feature-graphql/src/assets/images/codey-2.png +0 -0
- package/dist/force-app/main/default/webapplications/feature-graphql/src/assets/images/codey-3.png +0 -0
- package/dist/force-app/main/default/webapplications/feature-graphql/src/assets/images/vibe-codey.svg +0 -194
- package/dist/force-app/main/default/webapplications/feature-graphql/src/components/AccountsTable.tsx +0 -121
- package/dist/force-app/main/default/webapplications/feature-graphql/src/index.ts +0 -7
- package/dist/force-app/main/default/webapplications/feature-graphql/src/navigationMenu.tsx +0 -81
- package/dist/force-app/main/default/webapplications/feature-graphql/src/pages/About.tsx +0 -12
- package/dist/force-app/main/default/webapplications/feature-graphql/src/pages/AccountsPage.tsx +0 -19
- package/dist/force-app/main/default/webapplications/feature-graphql/src/pages/Home.tsx +0 -12
- package/dist/force-app/main/default/webapplications/feature-graphql/src/pages/NotFound.tsx +0 -18
- package/dist/force-app/main/default/webapplications/feature-graphql/src/pages/new.tsx +0 -10
- package/dist/force-app/main/default/webapplications/feature-graphql/src/router-utils.tsx +0 -34
- package/dist/force-app/main/default/webapplications/feature-graphql/src/routes.tsx +0 -48
- package/dist/force-app/main/default/webapplications/feature-graphql/src/styles/global.css +0 -13
- package/dist/force-app/main/default/webapplications/feature-graphql/tsconfig.json +0 -36
- package/dist/force-app/main/default/webapplications/feature-graphql/tsconfig.node.json +0 -13
- package/dist/force-app/main/default/webapplications/feature-graphql/vite-env.d.ts +0 -1
- package/dist/force-app/main/default/webapplications/feature-graphql/vite.config.ts +0 -69
- package/dist/force-app/main/default/webapplications/feature-graphql/vitest-env.d.ts +0 -2
- package/dist/force-app/main/default/webapplications/feature-graphql/vitest.config.ts +0 -11
- package/dist/force-app/main/default/webapplications/feature-graphql/vitest.setup.ts +0 -1
- package/dist/force-app/main/default/webapplications/feature-graphql/webapplication.json +0 -7
- package/dist/jest.config.js +0 -6
- package/dist/package.json +0 -37
- package/dist/scripts/apex/hello.apex +0 -10
- package/dist/scripts/soql/account.soql +0 -6
- package/dist/sfdx-project.json +0 -12
- package/skills/graphql-data-access/scripts/codegen.js +0 -15
- package/skills/graphql-data-access/scripts/get-graphql-schema.mjs +0 -59
- package/src/force-app/main/default/webapplications/feature-graphql/.graphqlrc.yml +0 -6
- package/src/force-app/main/default/webapplications/feature-graphql/src/api/graphql-operations-types.ts +0 -118
- package/src/force-app/main/default/webapplications/feature-graphql/src/api/graphql.test.ts +0 -91
- package/src/force-app/main/default/webapplications/feature-graphql/src/api/graphql.ts +0 -35
- package/src/force-app/main/default/webapplications/feature-graphql/src/api/utils/accounts.ts +0 -35
- package/src/force-app/main/default/webapplications/feature-graphql/src/api/utils/query/highRevenueAccountsQuery.graphql +0 -29
- package/src/force-app/main/default/webapplications/feature-graphql/src/api/utils/user.test.ts +0 -129
- package/src/force-app/main/default/webapplications/feature-graphql/src/api/utils/user.ts +0 -53
- package/src/force-app/main/default/webapplications/feature-graphql/src/components/AccountsTable.tsx +0 -121
- package/src/force-app/main/default/webapplications/feature-graphql/src/index.ts +0 -7
- package/src/force-app/main/default/webapplications/feature-graphql/src/pages/AccountsPage.tsx +0 -19
- package/src/force-app/main/default/webapplications/feature-graphql/src/routes.tsx +0 -20
- package/src/force-app/main/default/webapplications/feature-graphql/vite.config.ts +0 -69
package/README.md
CHANGED
|
@@ -1,46 +1,50 @@
|
|
|
1
1
|
# Feature: GraphQL Data Access
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> **Note:** GraphQL is now built into `@salesforce/webapp-template-base-react-app-experimental` by default. This package provides AI agent skills, rules, and documentation for GraphQL development.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
This package provides:
|
|
6
6
|
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
-
|
|
10
|
-
- [Skills](#skills)
|
|
7
|
+
- **Agent skills** for AI-assisted GraphQL development (schema exploration, query generation, mutation generation)
|
|
8
|
+
- **Rules** for consistent GraphQL patterns across AI coding agents
|
|
9
|
+
- **Documentation** and best practices for using GraphQL with Salesforce
|
|
11
10
|
|
|
12
|
-
##
|
|
11
|
+
## What's in the Base App
|
|
13
12
|
|
|
14
|
-
|
|
13
|
+
The base React app (`@salesforce/webapp-template-base-react-app-experimental`) includes all GraphQL tooling out of the box:
|
|
15
14
|
|
|
16
|
-
-
|
|
17
|
-
-
|
|
18
|
-
-
|
|
19
|
-
-
|
|
20
|
-
-
|
|
15
|
+
- `@salesforce/sdk-data` dependency
|
|
16
|
+
- GraphQL ESLint plugin and rules
|
|
17
|
+
- GraphQL codegen dependencies and configuration (`codegen.yml`)
|
|
18
|
+
- `executeGraphQL<T>()` utility and `gql` template tag
|
|
19
|
+
- Example components: `AccountsTable`, `AccountsPage`
|
|
20
|
+
- Type-safe GraphQL patterns with codegen
|
|
21
|
+
- `npm run graphql:schema` — download schema from a connected Salesforce org
|
|
22
|
+
- `npm run graphql:codegen` — generate TypeScript types from `.graphql` files and `gql` queries
|
|
21
23
|
|
|
22
|
-
|
|
24
|
+
All new apps built from `base-react-app` get GraphQL support out of the box.
|
|
23
25
|
|
|
24
|
-
|
|
25
|
-
import {
|
|
26
|
-
executeGraphQL,
|
|
27
|
-
gql,
|
|
28
|
-
AccountsTable,
|
|
29
|
-
} from "@salesforce/webapp-template-feature-graphql-experimental";
|
|
26
|
+
---
|
|
30
27
|
|
|
31
|
-
|
|
32
|
-
<AccountsTable />;
|
|
28
|
+
## Skills
|
|
33
29
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
30
|
+
> [https://docs.cline.bot/features/skills](https://docs.cline.bot/features/skills)
|
|
31
|
+
|
|
32
|
+
This package includes a **skill** for AI agents to generate GraphQL data access code:
|
|
33
|
+
|
|
34
|
+
- **graphql-data-access**: End-to-end workflow from schema exploration → query generation → type generation → implementation
|
|
35
|
+
- Includes knowledge docs for schema exploration, read query generation, and mutation query generation
|
|
36
|
+
- Includes the shared Salesforce GraphQL schema definition (`shared-schema.graphqls`)
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
**Installation:**
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
-
|
|
43
|
-
|
|
40
|
+
```bash
|
|
41
|
+
# Copy skill to your coding agent's skills directory
|
|
42
|
+
cp -r skills/graphql-data-access ~/.cursor/skills/
|
|
43
|
+
# Or for Cline:
|
|
44
|
+
cp -r skills/graphql-data-access ~/.cline/skills/
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
The skill references the base app's `npm run graphql:codegen` and `npm run graphql:schema` scripts — no additional setup needed.
|
|
44
48
|
|
|
45
49
|
---
|
|
46
50
|
|
|
@@ -48,57 +52,40 @@ const data = await executeGraphQL<MyQuery>(MY_QUERY, variables);
|
|
|
48
52
|
|
|
49
53
|
> [https://docs.cline.bot/features/cline-rules](https://docs.cline.bot/features/cline-rules)
|
|
50
54
|
|
|
51
|
-
|
|
55
|
+
This package includes **rules** that define conventions for GraphQL data access:
|
|
52
56
|
|
|
53
57
|
- Use `executeGraphQL<T>()` (never raw fetch/axios)
|
|
54
58
|
- Always provide response type generics
|
|
55
59
|
- Use `gql` tag or `.graphql` files (never plain strings)
|
|
56
60
|
- Follow the two-pattern workflow (external file vs. inline)
|
|
57
61
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
---
|
|
61
|
-
|
|
62
|
-
## Skills
|
|
63
|
-
|
|
64
|
-
> [https://docs.cline.bot/features/skills](https://docs.cline.bot/features/skills)
|
|
65
|
-
|
|
66
|
-
The feature includes a **skill** for AI agents to generate GraphQL data access code:
|
|
67
|
-
|
|
68
|
-
- **graphql-data-access**: End-to-end workflow from schema exploration → query generation → type generation → implementation
|
|
69
|
-
- Includes knowledge docs for schema exploration, read query generation, and mutation query generation
|
|
70
|
-
- Includes the shared Salesforce GraphQL schema definition (`shared-schema.graphqls`)
|
|
71
|
-
- Includes scripts for codegen and downloading org schema via introspection (`scripts/codegen.js`, `scripts/get-graphql-schema.mjs`)
|
|
62
|
+
**Installation:**
|
|
72
63
|
|
|
73
|
-
|
|
64
|
+
```bash
|
|
65
|
+
# Copy rules to your coding agent's rules directory
|
|
66
|
+
cp rules/graphql-data-access-rule.md ~/.cursor/rules/
|
|
67
|
+
# Or for Cline:
|
|
68
|
+
cp rules/graphql-data-access-rule.md ~/.clinerules/
|
|
69
|
+
```
|
|
74
70
|
|
|
75
71
|
---
|
|
76
72
|
|
|
77
|
-
##
|
|
73
|
+
## Reference Examples
|
|
78
74
|
|
|
79
|
-
|
|
75
|
+
The base React app includes reference examples:
|
|
80
76
|
|
|
81
|
-
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
-
|
|
86
|
-
- `@graphql-codegen/typescript` — TypeScript type generation plugin
|
|
87
|
-
- `@graphql-codegen/typescript-operations` — Operations type generation plugin
|
|
88
|
-
- `graphql-codegen-typescript-operation-types` — Operation types plugin
|
|
89
|
-
- `vite-plugin-graphql-codegen` — Vite integration for automatic codegen
|
|
90
|
-
- `graphql` — the official JavaScript implementation of the GraphQL Specification
|
|
77
|
+
- `src/api/graphql.ts` — Core `executeGraphQL()` utility
|
|
78
|
+
- `src/api/utils/accounts.ts` — Pattern 1 (external `.graphql` file + codegen types)
|
|
79
|
+
- `src/api/utils/user.ts` — Pattern 2 (inline `gql` tag)
|
|
80
|
+
- `src/components/AccountsTable.tsx` — Component using GraphQL to fetch and render Accounts
|
|
81
|
+
- `src/pages/AccountsPage.tsx` — Page wrapping the AccountsTable
|
|
91
82
|
|
|
92
83
|
---
|
|
93
84
|
|
|
94
|
-
##
|
|
95
|
-
|
|
96
|
-
You can test the extension of the base app and the components via the following:
|
|
85
|
+
## Installation
|
|
97
86
|
|
|
98
87
|
```bash
|
|
99
|
-
npm
|
|
100
|
-
npm run dev # run from dist
|
|
101
|
-
npm run watch # watch and re-apply
|
|
88
|
+
npm install @salesforce/webapp-template-feature-graphql-experimental
|
|
102
89
|
```
|
|
103
90
|
|
|
104
|
-
|
|
91
|
+
Then copy the skills and rules to your coding agent's directories (see above).
|
package/package.json
CHANGED
|
@@ -1,57 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/webapp-template-feature-graphql-experimental",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "GraphQL
|
|
3
|
+
"version": "1.36.0",
|
|
4
|
+
"description": "GraphQL documentation, agent skills, and rules for Salesforce web applications",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"author": "",
|
|
7
7
|
"type": "module",
|
|
8
|
-
"main": "src/force-app/main/default/webapplications/feature-graphql/src/index.ts",
|
|
9
|
-
"types": "src/force-app/main/default/webapplications/feature-graphql/src/index.ts",
|
|
10
|
-
"exports": {
|
|
11
|
-
".": {
|
|
12
|
-
"types": "./src/force-app/main/default/webapplications/feature-graphql/src/index.ts",
|
|
13
|
-
"import": "./src/force-app/main/default/webapplications/feature-graphql/src/index.ts",
|
|
14
|
-
"default": "./src/force-app/main/default/webapplications/feature-graphql/src/index.ts"
|
|
15
|
-
}
|
|
16
|
-
},
|
|
17
8
|
"files": [
|
|
18
|
-
"dist",
|
|
19
|
-
"src",
|
|
20
9
|
"rules",
|
|
21
|
-
"skills"
|
|
10
|
+
"skills",
|
|
11
|
+
"README.md"
|
|
22
12
|
],
|
|
23
13
|
"publishConfig": {
|
|
24
14
|
"access": "public"
|
|
25
15
|
},
|
|
26
16
|
"scripts": {
|
|
27
|
-
"clean": "
|
|
28
|
-
"dev": "cd dist/force-app/main/default/webapplications/feature-graphql && npm install && npm run dev",
|
|
29
|
-
"watch": "npx tsx ../../cli/src/index.ts watch-patches packages/template/feature/feature-graphql packages/template/base-app/base-react-app packages/template/feature/feature-graphql/dist"
|
|
30
|
-
},
|
|
31
|
-
"devDependencies": {
|
|
32
|
-
"@graphql-codegen/cli": "^6.1.0",
|
|
33
|
-
"@graphql-codegen/typescript": "^5.0.6",
|
|
34
|
-
"@graphql-codegen/typescript-operations": "^5.0.6",
|
|
35
|
-
"@salesforce/sdk-data": "^1.35.1",
|
|
36
|
-
"@salesforce/webapp-experimental": "^1.35.1",
|
|
37
|
-
"@types/react": "^19.2.7",
|
|
38
|
-
"@types/react-dom": "^19.2.3",
|
|
39
|
-
"graphql": "^16.11.0",
|
|
40
|
-
"graphql-codegen-typescript-operation-types": "^2.0.2",
|
|
41
|
-
"react-dom": "^19.2.1",
|
|
42
|
-
"react-router": "^7.10.1",
|
|
43
|
-
"vite": "^7.3.1",
|
|
44
|
-
"vite-plugin-graphql-codegen": "^3.6.3"
|
|
45
|
-
},
|
|
46
|
-
"nx": {
|
|
47
|
-
"targets": {
|
|
48
|
-
"build": {
|
|
49
|
-
"executor": "@salesforce/webapp-template-cli-experimental:apply-patches"
|
|
50
|
-
},
|
|
51
|
-
"test": {
|
|
52
|
-
"executor": "@salesforce/webapp-template-cli-experimental:build-dist-app"
|
|
53
|
-
}
|
|
54
|
-
}
|
|
17
|
+
"clean": "echo 'No build artifacts to clean'"
|
|
55
18
|
},
|
|
56
|
-
"gitHead": "
|
|
19
|
+
"gitHead": "b777854a57e42c3f676507c4b1ad27e23fbbd0d0"
|
|
57
20
|
}
|
|
@@ -17,12 +17,12 @@ Types are auto-generated at: `src/api/graphql-operations-types.ts`
|
|
|
17
17
|
### Generation Command
|
|
18
18
|
|
|
19
19
|
```bash
|
|
20
|
-
|
|
20
|
+
npm run graphql:codegen
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
-
The codegen configuration is
|
|
23
|
+
The codegen configuration is at `codegen.yml` and generates types from:
|
|
24
24
|
|
|
25
|
-
- Schema: `schema.graphql` (root
|
|
25
|
+
- Schema: `schema.graphql` (project root)
|
|
26
26
|
- Documents: `src/**/*.{graphql,ts,tsx}`
|
|
27
27
|
|
|
28
28
|
### Type Naming Convention
|
|
@@ -151,7 +151,7 @@ query GetMyData($myVariable: String) {
|
|
|
151
151
|
#### Step 2: Run Code Generation
|
|
152
152
|
|
|
153
153
|
```bash
|
|
154
|
-
|
|
154
|
+
npm run graphql:codegen
|
|
155
155
|
```
|
|
156
156
|
|
|
157
157
|
This generates types in `graphql-operations-types.ts`:
|
|
@@ -387,7 +387,7 @@ Before completing GraphQL data access code:
|
|
|
387
387
|
### For Pattern 1 (.graphql files):
|
|
388
388
|
|
|
389
389
|
1. [ ] Create `.graphql` file for the query/mutation
|
|
390
|
-
2. [ ] Run `
|
|
390
|
+
2. [ ] Run `npm run graphql:codegen` to generate types
|
|
391
391
|
3. [ ] Import query with `?raw` suffix
|
|
392
392
|
4. [ ] Import generated types from `graphql-operations-types.ts`
|
|
393
393
|
5. [ ] Use `executeGraphQL<ResponseType>()` with proper generic
|
|
@@ -14,52 +14,29 @@ Add or modify Salesforce GraphQL data access code using the established `execute
|
|
|
14
14
|
- User wants to add a new GraphQL operation (query or mutation)
|
|
15
15
|
- User asks to add data access for a Salesforce object (Account, Contact, Opportunity, etc.)
|
|
16
16
|
|
|
17
|
-
##
|
|
18
|
-
|
|
19
|
-
Before using this skill, ensure the following packages are installed in the project.
|
|
20
|
-
|
|
21
|
-
**Runtime** (required for `executeGraphQL` and `gql`):
|
|
22
|
-
|
|
23
|
-
```bash
|
|
24
|
-
npm install @salesforce/sdk-data
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
**Codegen** (required for type generation from `.graphql` files and inline `gql` queries):
|
|
28
|
-
|
|
29
|
-
```bash
|
|
30
|
-
npm install -D @graphql-codegen/cli @graphql-codegen/typescript @graphql-codegen/typescript-operations graphql-codegen-typescript-operation-types graphql
|
|
31
|
-
```
|
|
17
|
+
## Prerequisites
|
|
32
18
|
|
|
33
|
-
|
|
19
|
+
The base React app (`base-react-app`) ships with all GraphQL dependencies and tooling pre-configured:
|
|
34
20
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
21
|
+
- `@salesforce/sdk-data` — runtime SDK for `executeGraphQL` and `gql`
|
|
22
|
+
- `@graphql-codegen/cli` + plugins — type generation from `.graphql` files and inline `gql` queries
|
|
23
|
+
- `@graphql-eslint/eslint-plugin` — linting for `.graphql` files and `gql` template literals
|
|
24
|
+
- `graphql` — shared by codegen, ESLint, and schema introspection
|
|
38
25
|
|
|
39
|
-
|
|
26
|
+
Before using this skill, ensure:
|
|
40
27
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
1. The `api/graphql.ts` utility must exist in the project (provided by this feature)
|
|
44
|
-
2. A `schema.graphql` file should exist at the project root. If missing, generate it:
|
|
28
|
+
1. The `api/graphql.ts` utility exists in the project (provided by the base app)
|
|
29
|
+
2. A `schema.graphql` file exists at the project root. If missing, generate it:
|
|
45
30
|
```bash
|
|
46
|
-
|
|
31
|
+
npm run graphql:schema
|
|
47
32
|
```
|
|
48
33
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
## Scripts
|
|
34
|
+
## npm Scripts
|
|
52
35
|
|
|
53
|
-
|
|
36
|
+
The base app provides two npm scripts for GraphQL tooling:
|
|
54
37
|
|
|
55
|
-
- **`
|
|
56
|
-
|
|
57
|
-
npx graphql-codegen --config <this-skill>/scripts/codegen.js
|
|
58
|
-
```
|
|
59
|
-
- **`scripts/get-graphql-schema.mjs`** — Downloads the full GraphQL schema from a connected Salesforce org via introspection. Outputs `schema.graphql` to the project root.
|
|
60
|
-
```bash
|
|
61
|
-
node <this-skill>/scripts/get-graphql-schema.mjs
|
|
62
|
-
```
|
|
38
|
+
- **`npm run graphql:schema`** — Downloads the full GraphQL schema from a connected Salesforce org via introspection. Outputs `schema.graphql` to the project root.
|
|
39
|
+
- **`npm run graphql:codegen`** — Generates TypeScript types from `.graphql` files and inline `gql` queries. Outputs to `src/api/graphql-operations-types.ts`.
|
|
63
40
|
|
|
64
41
|
## Workflow
|
|
65
42
|
|
|
@@ -107,7 +84,7 @@ For **Pattern 2**:
|
|
|
107
84
|
### Step 4: Generate Types
|
|
108
85
|
|
|
109
86
|
```bash
|
|
110
|
-
|
|
87
|
+
npm run graphql:codegen
|
|
111
88
|
```
|
|
112
89
|
|
|
113
90
|
This updates `src/api/graphql-operations-types.ts` with:
|
|
@@ -163,5 +140,5 @@ export async function getSimpleData(): Promise<SomeType> {
|
|
|
163
140
|
- Read query generation: `docs/generate-read-query.md`
|
|
164
141
|
- Mutation query generation: `docs/generate-mutation-query.md`
|
|
165
142
|
- Shared GraphQL schema types: `docs/shared-schema.graphqls`
|
|
166
|
-
-
|
|
167
|
-
-
|
|
143
|
+
- Schema download: `npm run graphql:schema` (in the base app)
|
|
144
|
+
- Type generation: `npm run graphql:codegen` (in the base app)
|
|
@@ -11,7 +11,7 @@ This document provides guidance for AI agents working with the Salesforce GraphQ
|
|
|
11
11
|
If the file is not present, generate it by running:
|
|
12
12
|
|
|
13
13
|
```bash
|
|
14
|
-
|
|
14
|
+
npm run graphql:schema
|
|
15
15
|
```
|
|
16
16
|
|
|
17
17
|
## Required Pre-Flight Check
|
|
@@ -20,7 +20,7 @@ node <this-skill>/scripts/get-graphql-schema.mjs
|
|
|
20
20
|
|
|
21
21
|
1. **Check if schema exists**: Look for `schema.graphql` in the project root
|
|
22
22
|
2. **If schema is missing**:
|
|
23
|
-
- Run `
|
|
23
|
+
- Run `npm run graphql:schema` to download it
|
|
24
24
|
- Wait for the command to complete successfully
|
|
25
25
|
- Then proceed with schema exploration
|
|
26
26
|
3. **If schema exists**: Proceed with targeted searches as described below
|
|
@@ -229,7 +229,7 @@ Salesforce GraphQL returns field values wrapped in typed objects:
|
|
|
229
229
|
**Pre-requisites (MANDATORY):**
|
|
230
230
|
|
|
231
231
|
- [ ] Verified `schema.graphql` exists in project root
|
|
232
|
-
- [ ] If missing, ran `
|
|
232
|
+
- [ ] If missing, ran `npm run graphql:schema` and waited for completion
|
|
233
233
|
- [ ] Confirmed connection to correct Salesforce org (if downloading fresh schema)
|
|
234
234
|
|
|
235
235
|
**Workflow Steps:**
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
# AI Rule: Build Validation
|
|
2
|
-
|
|
3
|
-
Build validation for successful deployments with minimal friction.
|
|
4
|
-
|
|
5
|
-
## Targets
|
|
6
|
-
- `force-app/main/default/webapplications/*/**/*`
|
|
7
|
-
- `**/*.{js,ts,jsx,tsx}`
|
|
8
|
-
|
|
9
|
-
## MANDATORY: Build Success
|
|
10
|
-
|
|
11
|
-
**Before completing any coding session:**
|
|
12
|
-
```bash
|
|
13
|
-
npm run build # MUST succeed with no errors
|
|
14
|
-
```
|
|
15
|
-
|
|
16
|
-
## Quick Quality Checks
|
|
17
|
-
```bash
|
|
18
|
-
npm run format:check # Auto-fixable
|
|
19
|
-
npm run lint # Most issues auto-fixable
|
|
20
|
-
tsc -b # Catches major issues
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
## Requirements
|
|
24
|
-
|
|
25
|
-
**Must Pass:**
|
|
26
|
-
- `npm run build` completes successfully
|
|
27
|
-
- No TypeScript compilation errors
|
|
28
|
-
- No critical ESLint errors
|
|
29
|
-
|
|
30
|
-
**Can Be Warnings:**
|
|
31
|
-
- ESLint warnings
|
|
32
|
-
- Prettier formatting issues
|
|
33
|
-
- Minor TypeScript warnings
|
|
34
|
-
|
|
35
|
-
## Auto-Fix Commands
|
|
36
|
-
```bash
|
|
37
|
-
npm run fix-all # Fix formatting + linting
|
|
38
|
-
npm run format # Fix Prettier issues
|
|
39
|
-
npm run lint:fix # Fix ESLint issues
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
## Workflow
|
|
43
|
-
|
|
44
|
-
**During Development:**
|
|
45
|
-
1. Write code with AI assistance
|
|
46
|
-
2. Save frequently (auto-format on save)
|
|
47
|
-
3. Check periodically: `npm run lint` (optional)
|
|
48
|
-
|
|
49
|
-
**Before Completion:**
|
|
50
|
-
1. Run `npm run build`
|
|
51
|
-
2. If fails: Run `npm run fix-all`, fix TypeScript errors, retry build
|
|
52
|
-
|
|
53
|
-
## Error Priority
|
|
54
|
-
|
|
55
|
-
**Fix Immediately:**
|
|
56
|
-
- TypeScript compilation errors
|
|
57
|
-
- Import/export errors
|
|
58
|
-
- Syntax errors
|
|
59
|
-
|
|
60
|
-
**Fix When Convenient:**
|
|
61
|
-
- ESLint warnings
|
|
62
|
-
- Prettier formatting
|
|
63
|
-
- Unused variables
|
|
64
|
-
|
|
65
|
-
## Hard Requirements
|
|
66
|
-
- Build must complete without errors
|
|
67
|
-
- No broken imports
|
|
68
|
-
- Basic TypeScript type safety
|
|
69
|
-
|
|
70
|
-
## Key Commands
|
|
71
|
-
```bash
|
|
72
|
-
npm run dev # Start development
|
|
73
|
-
npm run build # Check deployment readiness
|
|
74
|
-
npm run fix-all # Fix common issues
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
## Troubleshooting Import Errors
|
|
78
|
-
```bash
|
|
79
|
-
npm install # Check missing dependencies
|
|
80
|
-
# Verify file exists, case sensitivity, export/import match
|
|
81
|
-
```
|
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
# AI Rule: Code Quality Standards
|
|
2
|
-
|
|
3
|
-
Enforces ESLint, Prettier, and coding best practices for consistent, maintainable code.
|
|
4
|
-
|
|
5
|
-
## Targets
|
|
6
|
-
- `force-app/main/default/webapplications/*/**/*`
|
|
7
|
-
- `**/*.{js,ts,jsx,tsx,json,md}`
|
|
8
|
-
|
|
9
|
-
## MANDATORY Checks
|
|
10
|
-
|
|
11
|
-
**Before writing code:**
|
|
12
|
-
```bash
|
|
13
|
-
npm run lint # MUST result in: 0 problems (0 errors, 0 warnings)
|
|
14
|
-
npm run format:check # MUST result in: All matched files use Prettier code style!
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
## Prettier Config (.prettierrc)
|
|
18
|
-
```json
|
|
19
|
-
{
|
|
20
|
-
"semi": true,
|
|
21
|
-
"trailingComma": "es5",
|
|
22
|
-
"singleQuote": true,
|
|
23
|
-
"printWidth": 80,
|
|
24
|
-
"tabWidth": 2,
|
|
25
|
-
"useTabs": false,
|
|
26
|
-
"bracketSpacing": true,
|
|
27
|
-
"arrowParens": "avoid",
|
|
28
|
-
"endOfLine": "lf"
|
|
29
|
-
}
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
## Auto-Fix Commands
|
|
33
|
-
```bash
|
|
34
|
-
npm run fix-all # Fix formatting + linting (recommended)
|
|
35
|
-
npm run format # Fix Prettier issues
|
|
36
|
-
npm run lint:fix # Fix ESLint issues
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
## Import Order (MANDATORY)
|
|
40
|
-
```typescript
|
|
41
|
-
// 1. React ecosystem
|
|
42
|
-
import { useState, useEffect } from 'react';
|
|
43
|
-
|
|
44
|
-
// 2. External libraries (alphabetical)
|
|
45
|
-
import axios from 'axios';
|
|
46
|
-
import clsx from 'clsx';
|
|
47
|
-
|
|
48
|
-
// 3. UI components (alphabetical)
|
|
49
|
-
import { Button } from '@/components/ui/button';
|
|
50
|
-
import { Card } from '@/components/ui/card';
|
|
51
|
-
|
|
52
|
-
// 4. Internal utilities (alphabetical)
|
|
53
|
-
import { useAuth } from '../hooks/useAuth';
|
|
54
|
-
import { formatDate } from '../utils/dateUtils';
|
|
55
|
-
|
|
56
|
-
// 5. Relative imports
|
|
57
|
-
import { ComponentA } from './ComponentA';
|
|
58
|
-
|
|
59
|
-
// 6. Type imports (separate, at end)
|
|
60
|
-
import type { User, ApiResponse } from '../types';
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
## Naming Conventions
|
|
64
|
-
```typescript
|
|
65
|
-
// PascalCase: Components, classes
|
|
66
|
-
const UserProfile = () => {};
|
|
67
|
-
const ApiClient = class {};
|
|
68
|
-
|
|
69
|
-
// camelCase: Variables, functions, properties
|
|
70
|
-
const userName = 'john';
|
|
71
|
-
const fetchUserData = async () => {};
|
|
72
|
-
|
|
73
|
-
// SCREAMING_SNAKE_CASE: Constants
|
|
74
|
-
const API_BASE_URL = 'https://api.example.com';
|
|
75
|
-
|
|
76
|
-
// kebab-case: Files
|
|
77
|
-
// user-profile.tsx, api-client.ts
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
## React Component Structure
|
|
81
|
-
```typescript
|
|
82
|
-
interface ComponentProps {
|
|
83
|
-
// Props interface first
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
const Component: React.FC<ComponentProps> = ({ prop1, prop2 }) => {
|
|
87
|
-
// 1. Hooks
|
|
88
|
-
// 2. Computed values
|
|
89
|
-
// 3. Event handlers
|
|
90
|
-
// 4. JSX return
|
|
91
|
-
|
|
92
|
-
return <div />;
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
export default Component;
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
## JSX Standards
|
|
99
|
-
```typescript
|
|
100
|
-
// Self-closing tags
|
|
101
|
-
<Button onClick={handleClick} />
|
|
102
|
-
|
|
103
|
-
// Conditional rendering
|
|
104
|
-
{isLoading && <Spinner />}
|
|
105
|
-
{error ? <ErrorMessage error={error} /> : <Content />}
|
|
106
|
-
|
|
107
|
-
// Lists with keys
|
|
108
|
-
{items.map(item => <Item key={item.id} data={item} />)}
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
## Error Handling
|
|
112
|
-
```typescript
|
|
113
|
-
// Async functions with try-catch
|
|
114
|
-
const fetchData = async (id: string): Promise<Data> => {
|
|
115
|
-
try {
|
|
116
|
-
const response = await api.get(`/data/${id}`);
|
|
117
|
-
return response.data;
|
|
118
|
-
} catch (error) {
|
|
119
|
-
console.error('Failed to fetch data:', error);
|
|
120
|
-
throw error;
|
|
121
|
-
}
|
|
122
|
-
};
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
## Anti-Patterns (FORBIDDEN)
|
|
126
|
-
```typescript
|
|
127
|
-
// NEVER disable ESLint without justification
|
|
128
|
-
// eslint-disable-next-line
|
|
129
|
-
|
|
130
|
-
// NEVER mutate state directly
|
|
131
|
-
state.items.push(newItem); // Wrong
|
|
132
|
-
setItems(prev => [...prev, newItem]); // Correct
|
|
133
|
-
|
|
134
|
-
// NEVER use magic numbers/strings
|
|
135
|
-
setTimeout(() => {}, 5000); // Wrong
|
|
136
|
-
const DEBOUNCE_DELAY = 5000; // Correct
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
## Quality Workflow
|
|
140
|
-
|
|
141
|
-
**Before Committing:**
|
|
142
|
-
1. `npm run check-all` - All checks must pass
|
|
143
|
-
2. `npm run fix-all` - Auto-fix issues if needed
|
|
144
|
-
3. `npm run build` - Build must succeed
|
|
145
|
-
|
|
146
|
-
## Zero Tolerance Policy
|
|
147
|
-
- ESLint errors: MUST be 0
|
|
148
|
-
- ESLint warnings: MUST be 0
|
|
149
|
-
- Prettier violations: MUST be 0
|
|
150
|
-
- TypeScript errors: MUST be 0
|