@salesforce/afv-skills 1.1.0 → 1.3.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.
Files changed (150) hide show
  1. package/package.json +6 -5
  2. package/skills/accessing-webapp-data/SKILL.md +178 -0
  3. package/skills/agentforce-development/SKILL.md +427 -0
  4. package/skills/agentforce-development/assets/README-legacy.md +89 -0
  5. package/skills/agentforce-development/assets/agent-spec-template.md +90 -0
  6. package/skills/agentforce-development/assets/agents/README.md +45 -0
  7. package/skills/agentforce-development/assets/agents/hello-world.agent +60 -0
  8. package/skills/agentforce-development/assets/agents/multi-topic.agent +105 -0
  9. package/skills/agentforce-development/assets/agents/production-faq.agent +101 -0
  10. package/skills/agentforce-development/assets/agents/production-faq.bundle-meta.xml +4 -0
  11. package/skills/agentforce-development/assets/agents/simple-qa.agent +72 -0
  12. package/skills/agentforce-development/assets/apex/models-api-queueable.cls +225 -0
  13. package/skills/agentforce-development/assets/bundle-meta.xml +23 -0
  14. package/skills/agentforce-development/assets/components/apex-action.agent +52 -0
  15. package/skills/agentforce-development/assets/components/error-handling.agent +58 -0
  16. package/skills/agentforce-development/assets/components/escalation-setup.agent +169 -0
  17. package/skills/agentforce-development/assets/components/flow-action.agent +66 -0
  18. package/skills/agentforce-development/assets/components/n-ary-conditions.agent +110 -0
  19. package/skills/agentforce-development/assets/components/topic-with-actions.agent +40 -0
  20. package/skills/agentforce-development/assets/deterministic-routing.agent +166 -0
  21. package/skills/agentforce-development/assets/escalation-pattern.agent +209 -0
  22. package/skills/agentforce-development/assets/flow-action-lookup.agent +115 -0
  23. package/skills/agentforce-development/assets/hub-and-spoke.agent +104 -0
  24. package/skills/agentforce-development/assets/invocable-apex-template.cls +187 -0
  25. package/skills/agentforce-development/assets/local-info-agent-annotated.agent +355 -0
  26. package/skills/agentforce-development/assets/metadata/basic-prompt-template.promptTemplate-meta.xml +109 -0
  27. package/skills/agentforce-development/assets/metadata/genai-function-apex.xml +92 -0
  28. package/skills/agentforce-development/assets/metadata/genai-function-flow.xml +57 -0
  29. package/skills/agentforce-development/assets/metadata/genai-plugin.xml +72 -0
  30. package/skills/agentforce-development/assets/metadata/http-callout-flow.flow-meta.xml +348 -0
  31. package/skills/agentforce-development/assets/metadata/record-grounded-prompt.promptTemplate-meta.xml +136 -0
  32. package/skills/agentforce-development/assets/minimal-starter.agent +42 -0
  33. package/skills/agentforce-development/assets/patterns/README.md +254 -0
  34. package/skills/agentforce-development/assets/patterns/action-callbacks.agent +178 -0
  35. package/skills/agentforce-development/assets/patterns/advanced-input-bindings.agent +141 -0
  36. package/skills/agentforce-development/assets/patterns/bidirectional-routing.agent +156 -0
  37. package/skills/agentforce-development/assets/patterns/critical-input-collection.agent +244 -0
  38. package/skills/agentforce-development/assets/patterns/delegation-routing.agent +89 -0
  39. package/skills/agentforce-development/assets/patterns/lifecycle-events.agent +127 -0
  40. package/skills/agentforce-development/assets/patterns/llm-controlled-actions.agent +184 -0
  41. package/skills/agentforce-development/assets/patterns/multi-step-workflow.agent +282 -0
  42. package/skills/agentforce-development/assets/patterns/open-gate-routing.agent +286 -0
  43. package/skills/agentforce-development/assets/patterns/procedural-instructions.agent +273 -0
  44. package/skills/agentforce-development/assets/patterns/prompt-template-action.agent +188 -0
  45. package/skills/agentforce-development/assets/patterns/system-instruction-overrides.agent +293 -0
  46. package/skills/agentforce-development/assets/prompt-rag-search.agent +131 -0
  47. package/skills/agentforce-development/assets/template-multi-topic.agent +160 -0
  48. package/skills/agentforce-development/assets/template-single-topic.agent +81 -0
  49. package/skills/agentforce-development/assets/verification-gate.agent +208 -0
  50. package/skills/agentforce-development/references/action-prompt-templates.md +164 -0
  51. package/skills/agentforce-development/references/actions-reference.md +592 -0
  52. package/skills/agentforce-development/references/agent-access-guide.md +72 -0
  53. package/skills/agentforce-development/references/agent-design-and-spec-creation.md +1010 -0
  54. package/skills/agentforce-development/references/agent-metadata-and-lifecycle.md +575 -0
  55. package/skills/agentforce-development/references/agent-script-core-language.md +1218 -0
  56. package/skills/agentforce-development/references/agent-topic-map-diagrams.md +323 -0
  57. package/skills/agentforce-development/references/agent-user-setup.md +526 -0
  58. package/skills/agentforce-development/references/agent-validation-and-debugging.md +803 -0
  59. package/skills/agentforce-development/references/known-issues.md +353 -0
  60. package/skills/agentforce-development/references/minimal-examples.md +67 -0
  61. package/skills/agentforce-development/references/production-gotchas.md +279 -0
  62. package/skills/agentforce-development/references/salesforce-cli-for-agents.md +393 -0
  63. package/skills/agentforce-development/references/version-history.md +23 -0
  64. package/skills/building-webapp-data-visualization/SKILL.md +72 -0
  65. package/skills/building-webapp-data-visualization/implementation/bar-line-chart.md +316 -0
  66. package/skills/building-webapp-data-visualization/implementation/dashboard-layout.md +189 -0
  67. package/skills/building-webapp-data-visualization/implementation/donut-chart.md +181 -0
  68. package/skills/building-webapp-data-visualization/implementation/stat-card.md +150 -0
  69. package/skills/building-webapp-react-components/SKILL.md +96 -0
  70. package/skills/building-webapp-react-components/implementation/component.md +78 -0
  71. package/skills/building-webapp-react-components/implementation/header-footer.md +132 -0
  72. package/skills/building-webapp-react-components/implementation/page.md +93 -0
  73. package/skills/configuring-webapp-csp-trusted-sites/SKILL.md +90 -0
  74. package/skills/configuring-webapp-csp-trusted-sites/implementation/metadata-format.md +281 -0
  75. package/skills/configuring-webapp-metadata/SKILL.md +158 -0
  76. package/skills/creating-webapp/SKILL.md +141 -0
  77. package/skills/deploying-webapp-to-salesforce/SKILL.md +229 -0
  78. package/skills/exploring-webapp-graphql-schema/SKILL.md +149 -0
  79. package/skills/fetching-webapp-rest-api/SKILL.md +167 -0
  80. package/skills/{salesforce-custom-application → generating-custom-application}/SKILL.md +2 -4
  81. package/skills/{salesforce-custom-field → generating-custom-field}/SKILL.md +1 -5
  82. package/skills/{salesforce-custom-lightning-type → generating-custom-lightning-type}/SKILL.md +36 -2
  83. package/skills/{salesforce-custom-object → generating-custom-object}/SKILL.md +1 -1
  84. package/skills/generating-custom-tab/SKILL.md +154 -0
  85. package/skills/generating-experience-lwr-site/SKILL.md +196 -0
  86. package/skills/generating-experience-lwr-site/docs/bootstrap-template-byo-lwr.md +224 -0
  87. package/skills/generating-experience-lwr-site/docs/configure-content-brandingSet.md +131 -0
  88. package/skills/generating-experience-lwr-site/docs/configure-content-route.md +232 -0
  89. package/skills/generating-experience-lwr-site/docs/configure-content-themeLayout.md +141 -0
  90. package/skills/generating-experience-lwr-site/docs/configure-content-view.md +233 -0
  91. package/skills/generating-experience-lwr-site/docs/configure-guest-sharing-rules.md +42 -0
  92. package/skills/generating-experience-lwr-site/docs/handle-component-and-region-ids.md +27 -0
  93. package/skills/generating-experience-lwr-site/docs/handle-ui-components.md +215 -0
  94. package/skills/generating-experience-react-site/SKILL.md +67 -0
  95. package/skills/generating-experience-react-site/docs/configure-metadata-custom-site.md +41 -0
  96. package/skills/generating-experience-react-site/docs/configure-metadata-digital-experience-bundle.md +17 -0
  97. package/skills/generating-experience-react-site/docs/configure-metadata-digital-experience-config.md +21 -0
  98. package/skills/generating-experience-react-site/docs/configure-metadata-digital-experience.md +38 -0
  99. package/skills/generating-experience-react-site/docs/configure-metadata-network.md +72 -0
  100. package/skills/{salesforce-flexipage → generating-flexipage}/SKILL.md +86 -9
  101. package/skills/{salesforce-flow → generating-flow}/SKILL.md +3 -3
  102. package/skills/generating-fragment/SKILL.md +117 -0
  103. package/skills/generating-lightning-app/SKILL.md +423 -0
  104. package/skills/{salesforce-list-view → generating-list-view}/SKILL.md +1 -1
  105. package/skills/generating-permission-set/SKILL.md +174 -0
  106. package/skills/{salesforce-validation-rule → generating-validation-rule}/SKILL.md +1 -1
  107. package/skills/generating-webapp-graphql-mutation-query/SKILL.md +258 -0
  108. package/skills/generating-webapp-graphql-read-query/SKILL.md +253 -0
  109. package/skills/implementing-webapp-file-upload/SKILL.md +396 -0
  110. package/skills/installing-webapp-features/SKILL.md +210 -0
  111. package/skills/managing-webapp-agentforce-conversation-client/SKILL.md +186 -0
  112. package/skills/managing-webapp-agentforce-conversation-client/references/constraints.md +134 -0
  113. package/skills/managing-webapp-agentforce-conversation-client/references/examples.md +132 -0
  114. package/skills/managing-webapp-agentforce-conversation-client/references/style-tokens.md +101 -0
  115. package/skills/managing-webapp-agentforce-conversation-client/references/troubleshooting.md +57 -0
  116. package/skills/switching-org/SKILL.md +28 -0
  117. package/skills/using-webapp-graphql/SKILL.md +324 -0
  118. package/skills/using-webapp-graphql/shared-schema.graphqls +1150 -0
  119. package/skills/apex-class/SKILL.md +0 -253
  120. package/skills/apex-class/examples/AccountDeduplicationBatch.cls +0 -148
  121. package/skills/apex-class/examples/AccountSelector.cls +0 -193
  122. package/skills/apex-class/examples/AccountService.cls +0 -201
  123. package/skills/apex-class/templates/abstract.cls +0 -128
  124. package/skills/apex-class/templates/batch.cls +0 -125
  125. package/skills/apex-class/templates/domain.cls +0 -102
  126. package/skills/apex-class/templates/dto.cls +0 -108
  127. package/skills/apex-class/templates/exception.cls +0 -51
  128. package/skills/apex-class/templates/interface.cls +0 -25
  129. package/skills/apex-class/templates/queueable.cls +0 -92
  130. package/skills/apex-class/templates/schedulable.cls +0 -75
  131. package/skills/apex-class/templates/selector.cls +0 -92
  132. package/skills/apex-class/templates/service.cls +0 -69
  133. package/skills/apex-class/templates/utility.cls +0 -97
  134. package/skills/apex-test-class/SKILL.md +0 -101
  135. package/skills/apex-test-class/references/assertion-patterns.md +0 -209
  136. package/skills/apex-test-class/references/async-testing.md +0 -276
  137. package/skills/apex-test-class/references/mocking-patterns.md +0 -219
  138. package/skills/apex-test-class/references/test-data-factory.md +0 -176
  139. package/skills/deployment-readiness-check/SKILL.md +0 -257
  140. package/skills/deployment-readiness-check/assets/deployment_checklist.md +0 -286
  141. package/skills/deployment-readiness-check/references/rollback_procedures.md +0 -308
  142. package/skills/deployment-readiness-check/scripts/check_metadata.sh +0 -207
  143. package/skills/salesforce-custom-tab/SKILL.md +0 -78
  144. package/skills/salesforce-experience-site/SKILL.md +0 -178
  145. package/skills/salesforce-fragment/SKILL.md +0 -42
  146. package/skills/salesforce-lightning-app-build/SKILL.md +0 -254
  147. package/skills/salesforce-web-app-creating-records/SKILL.md +0 -84
  148. package/skills/salesforce-web-app-feature/SKILL.md +0 -70
  149. package/skills/salesforce-web-app-list-and-create-records/SKILL.md +0 -36
  150. package/skills/salesforce-web-application/SKILL.md +0 -34
@@ -0,0 +1,101 @@
1
+ # Style Tokens Reference
2
+
3
+ This document explains how to use `styleTokens` for theming and styling the AgentforceConversationClient.
4
+
5
+ ## Overview
6
+
7
+ The `styleTokens` prop is the **ONLY** way to customize the appearance of the Agentforce conversation client. It accepts an object with style token keys and CSS values.
8
+
9
+ ## Source of Truth
10
+
11
+ For the complete and always up-to-date list of all 60+ style tokens, see:
12
+
13
+ **[@salesforce/agentforce-conversation-client on npm](https://www.npmjs.com/package/@salesforce/agentforce-conversation-client)**
14
+
15
+ The npm package README contains the definitive documentation with all available style tokens.
16
+
17
+ ## Token Categories
18
+
19
+ Style tokens are organized by UI area:
20
+
21
+ - **Header** (7 tokens): background, text color, hover, active, focus, border, font family
22
+ - **Messages** (10 tokens): colors, padding, margins, border radius, fonts, body width
23
+ - **Inbound messages** (5 tokens): background, text color, width, alignment, hover
24
+ - **Outbound messages** (5 tokens): background, text color, width, alignment, margin
25
+ - **Input** (33 tokens): colors, borders, fonts, padding, buttons, scrollbar, textarea, actions
26
+
27
+ ## Common Use Cases
28
+
29
+ ### Change header color
30
+
31
+ ```tsx
32
+ <AgentforceConversationClient
33
+ agentId="0Xx..."
34
+ styleTokens={{
35
+ headerBlockBackground: "#0176d3",
36
+ headerBlockTextColor: "#ffffff",
37
+ }}
38
+ />
39
+ ```
40
+
41
+ ### Change message colors
42
+
43
+ ```tsx
44
+ <AgentforceConversationClient
45
+ agentId="0Xx..."
46
+ styleTokens={{
47
+ messageBlockInboundBackgroundColor: "#4CAF50",
48
+ messageBlockInboundTextColor: "#ffffff",
49
+ messageBlockOutboundBackgroundColor: "#f5f5f5",
50
+ messageBlockOutboundTextColor: "#333333",
51
+ }}
52
+ />
53
+ ```
54
+
55
+ ### Apply brand colors
56
+
57
+ ```tsx
58
+ <AgentforceConversationClient
59
+ agentId="0Xx..."
60
+ styleTokens={{
61
+ headerBlockBackground: "#1a73e8",
62
+ headerBlockTextColor: "#ffffff",
63
+ messageBlockInboundBackgroundColor: "#1a73e8",
64
+ messageBlockInboundTextColor: "#ffffff",
65
+ messageInputFooterSendButton: "#1a73e8",
66
+ messageInputFooterSendButtonHoverColor: "#1557b0",
67
+ }}
68
+ />
69
+ ```
70
+
71
+ ### Adjust spacing and fonts
72
+
73
+ ```tsx
74
+ <AgentforceConversationClient
75
+ agentId="0Xx..."
76
+ styleTokens={{
77
+ messageInputFontSize: "16px",
78
+ messageBlockBorderRadius: "12px",
79
+ messageBlockPadding: "16px",
80
+ messageInputPadding: "12px",
81
+ }}
82
+ />
83
+ ```
84
+
85
+ ## How to Find Token Names
86
+
87
+ 1. Check the [@salesforce/agentforce-conversation-client npm package](https://www.npmjs.com/package/@salesforce/agentforce-conversation-client) for the complete list of all tokens
88
+
89
+ 2. Token names follow a pattern:
90
+ - `headerBlock*` - Header area
91
+ - `messageBlock*` - Message bubbles
92
+ - `messageBlockInbound*` - Messages from customer to agent
93
+ - `messageBlockOutbound*` - Messages from agent to customer
94
+ - `messageInput*` - Input field and send button
95
+
96
+ ## Important Notes
97
+
98
+ - You do NOT need to provide all tokens - only override the ones you want to change
99
+ - Token values are CSS strings (e.g., `"#FF0000"`, `"16px"`, `"bold"`)
100
+ - Invalid token names are silently ignored
101
+ - The component uses default values for any tokens you don't specify
@@ -0,0 +1,57 @@
1
+ # Troubleshooting
2
+
3
+ Common issues when using the Agentforce Conversation Client.
4
+
5
+ ---
6
+
7
+ ### Component throws "requires agentId"
8
+
9
+ **Cause:** `agentId` was not passed.
10
+
11
+ **Solution:** Pass `agentId` directly as a flat prop:
12
+
13
+ ```tsx
14
+ <AgentforceConversationClient agentId="0Xx000000000000AAA" />
15
+ ```
16
+
17
+ ---
18
+
19
+ ### Chat widget does not appear
20
+
21
+ **Cause:** Invalid `agentId` or inactive agent.
22
+
23
+ **Solution:**
24
+
25
+ 1. Confirm the id is correct (18-char Salesforce id, starts with `0Xx`).
26
+ 2. Ensure the agent is Active in **Setup → Agentforce Agents**.
27
+ 3. Verify the agent is deployed to the target channel.
28
+
29
+ ---
30
+
31
+ ### Authentication error on localhost
32
+
33
+ **Cause:** `localhost:<PORT>` is not trusted for inline frames.
34
+
35
+ **Solution:**
36
+
37
+ 1. Go to **Setup → Session Settings → Trusted Domains for Inline Frames**.
38
+ 2. Add `localhost:<PORT>` (example: `localhost:3000`).
39
+
40
+ **Important:**
41
+
42
+ - This setting should be **temporary for local development only**.
43
+ - **Remove `localhost:<PORT>` from trusted domains after development**.
44
+ - **Recommended:** Test the Agentforce conversation client in a deployed app instead of relying on localhost trusted domains for extended periods.
45
+
46
+ ---
47
+
48
+ ### Blank iframe / auth session issues
49
+
50
+ **Possible cause:** First-party Salesforce cookie restriction may block embedded auth flow in some environments.
51
+
52
+ **Solution:**
53
+
54
+ 1. Go to **Setup → Session Settings**.
55
+ 2. Find **Require first party use of Salesforce cookies**.
56
+ 3. Disable it **only if needed and approved by your security/admin team**.
57
+ 4. Save and reload.
@@ -0,0 +1,28 @@
1
+ ---
2
+ name: switching-org
3
+ description: Switches the active Salesforce org (default target-org) using the Salesforce CLI. Use whenever someone wants to change which org CLI commands run against — whether they say "switch org", "change default org", "set my org to", "use alias", "point to", or describe wanting to work against a specific org, scratch org, sandbox, or production.
4
+ compatibility: Salesforce CLI (sf) v2+
5
+ metadata:
6
+ version: "1.0"
7
+ ---
8
+
9
+ ## Steps
10
+
11
+ 1. Identify the org: the user provides a username or alias (`orgIdentifier`). If not provided, run `sf org list` to show authenticated orgs and ask the user which one to use.
12
+ 2. Set the default org:
13
+ - Local (default): `sf config set target-org <orgIdentifier>`
14
+ - Applies only within the current project directory. Use this for normal project work.
15
+ - Global (only if user explicitly requests): `sf config set target-org <orgIdentifier> --global`
16
+ - Applies system-wide across all directories. Use when working outside a project or when the user asks for global scope.
17
+ - If this fails, report the error and suggest running `sf org login web` if the org may not be authorized.
18
+ 3. Verify:
19
+ - `sf config get target-org --json`
20
+ - Note: the JSON output does not include a scope/location field — it cannot confirm whether the value is local or global. Confirm the value only, e.g.: `target-org is now set to: <value>`
21
+ - If it fails, report the error and advise running `sf config get target-org`.
22
+
23
+ ## Notes
24
+
25
+ - Unified CLI uses keys like `target-org` and `target-dev-hub`. Legacy sfdx keys (`defaultusername`, `defaultdevhubusername`) are deprecated in this context.
26
+ - The sf CLI does not have `--local` or `--scope` flags for config set. Local scope is the default behavior.
27
+ - If the org does not change after setting the config, check whether `SF_TARGET_ORG` is set — environment variables override config values.
28
+ - Salesforce CLI config (unified) reference: https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_config_commands_unified.htm#cli_reference_config_set_unified
@@ -0,0 +1,324 @@
1
+ ---
2
+ name: using-webapp-graphql
3
+ description: Salesforce GraphQL data access. Use when the user asks to fetch, query, or mutate Salesforce data, or add a GraphQL operation for an object like Account, Contact, or Opportunity.
4
+ paths:
5
+ - "**/*.ts"
6
+ - "**/*.tsx"
7
+ - "**/*.graphql"
8
+ ---
9
+
10
+ # Salesforce GraphQL
11
+
12
+ Guidance for querying and mutating Salesforce data via the Salesforce GraphQL API. Use `createDataSDK()` + `sdk.graphql?.()` and codegen tooling.
13
+
14
+ ## When to Use
15
+
16
+ - User asks to "fetch data from Salesforce"
17
+ - User asks to "query" or "mutate" Salesforce records
18
+ - User wants to add a new GraphQL operation (query or mutation)
19
+ - User asks to add data access for a Salesforce object (Account, Contact, Opportunity, etc.)
20
+
21
+ ## Schema Access Policy (GREP ONLY)
22
+
23
+ > **GREP ONLY** — The `schema.graphql` file is very large (~265,000+ lines). All schema lookups **MUST** use the grep-only commands defined in the `exploring-graphql-schema` skill. Do NOT open, read, stream, or parse `./schema.graphql` with any tool other than grep.
24
+
25
+ ## Directory Context
26
+
27
+ The generated app has a two-level directory structure. Commands must run from the correct directory.
28
+
29
+ ```
30
+ <project-root>/ ← SFDX project root
31
+ ├── schema.graphql ← grep target
32
+ ├── sfdx-project.json
33
+ └── force-app/main/default/webapplications/<app-name>/ ← webapp dir
34
+ ├── package.json (npm scripts: graphql:schema, graphql:codegen, lint)
35
+ ├── eslint.config.js (schema ref: ../../../../../schema.graphql)
36
+ ├── codegen.yml (schema ref: ../../../../../schema.graphql)
37
+ └── src/ (source code, .graphql query files)
38
+ ```
39
+
40
+ | Command | Run from | Why |
41
+ | ------------------------- | ---------------- | -------------------------------------- |
42
+ | `npm run graphql:schema` | **webapp dir** | Script is in webapp's `package.json` |
43
+ | `npm run graphql:codegen` | **webapp dir** | Reads `codegen.yml` in webapp dir |
44
+ | `npx eslint <file>` | **webapp dir** | Reads `eslint.config.js` in webapp dir |
45
+ | `grep ... schema.graphql` | **project root** | `schema.graphql` lives at project root |
46
+ | `sf api request graphql` | **project root** | Needs `sfdx-project.json` |
47
+
48
+ > **Wrong directory = silent failures.** `npm run graphql:schema` from the project root will fail with "missing script." `grep ./schema.graphql` from the webapp dir will fail with "no such file."
49
+
50
+ ## Prerequisites
51
+
52
+ The base React app (`base-react-app`) ships with all GraphQL dependencies and tooling pre-configured:
53
+
54
+ - `@salesforce/sdk-data` — runtime SDK for `createDataSDK` and `gql`
55
+ - `@graphql-codegen/cli` + plugins — type generation from `.graphql` files and inline `gql` queries
56
+ - `@graphql-eslint/eslint-plugin` — validates `.graphql` files and `gql` template literals against `schema.graphql` (used as a query validation gate — see Step 6)
57
+ - `graphql` — shared by codegen, ESLint, and schema introspection
58
+
59
+ Before using this skill, ensure:
60
+
61
+ 1. The `@salesforce/sdk-data` package is available (provides `createDataSDK`, `gql`, `NodeOfConnection`)
62
+ 2. **Deployment order**: Metadata must be deployed before schema fetch; schema must be refetched after any metadata deployment. Invoke the `deploying-to-salesforce` skill when deploying or syncing with the org.
63
+ 3. A `schema.graphql` file exists at the project root. If missing, generate it:
64
+ ```bash
65
+ # Run from webapp dir (force-app/main/default/webapplications/<app-name>/)
66
+ npm run graphql:schema
67
+ ```
68
+
69
+ ## npm Scripts
70
+
71
+ - **`npm run graphql:schema`** — _(run from webapp dir)_ Downloads the full GraphQL schema from a connected Salesforce org via introspection. Outputs `schema.graphql` to the project root.
72
+ - **`npm run graphql:codegen`** — _(run from webapp dir)_ Generates TypeScript types from `.graphql` files and inline `gql` queries. Outputs to `src/api/graphql-operations-types.ts`.
73
+
74
+ ## Workflow
75
+
76
+ ### Step 1: Download Schema
77
+
78
+ Ensure `schema.graphql` exists at the project root. If missing, run `npm run graphql:schema` from the webapp dir.
79
+
80
+ ### Step 2: Explore the Schema (grep-only)
81
+
82
+ Before writing any query, verify the target object and its fields exist in the schema.
83
+
84
+ **Invoke the `exploring-graphql-schema` skill** for the full exploration workflow and **mandatory grep-only access policy**.
85
+
86
+ > **GREP ONLY** — All schema lookups MUST use the grep commands defined in the `exploring-graphql-schema` skill. Do NOT open, read, stream, or parse `./schema.graphql` with any tool other than grep.
87
+
88
+ Key actions (all via grep):
89
+
90
+ - `type <ObjectName> implements Record` — find available fields
91
+ - `input <ObjectName>_Filter` — find filter options
92
+ - `input <ObjectName>_OrderBy` — find sorting options
93
+ - `input <ObjectName>CreateInput` / `<ObjectName>UpdateInput` — find mutation input types
94
+
95
+ ### Step 3: Choose the Query Pattern
96
+
97
+ **Pattern 1 — External `.graphql` file** (recommended for complex queries):
98
+
99
+ - Queries with variables, fragments, or shared across files
100
+ - Full codegen support, syntax highlighting, shareable
101
+ - Requires codegen step after changes
102
+ - See example: `api/utils/accounts.ts` + `api/utils/query/highRevenueAccountsQuery.graphql`
103
+
104
+ **Pattern 2 — Inline `gql` tag** (recommended for simple queries):
105
+
106
+ - Simple queries without variables; colocated with usage code
107
+ - Supports dynamic queries (field set varies at runtime)
108
+ - **MUST use `gql` tag** — plain template strings bypass `@graphql-eslint` validation
109
+ - See example: `api/utils/user.ts`
110
+
111
+ ### Step 4: Write the Query
112
+
113
+ For **Pattern 1**:
114
+
115
+ 1. Create a `.graphql` file under `src/api/utils/query/`
116
+ 2. Follow UIAPI structure: `query { uiapi { query { ObjectName(...) { edges { node { ... } } } } } }`
117
+ 3. For mutations, invoke the `generating-graphql-mutation-query` skill
118
+ 4. For read queries, invoke the `generating-graphql-read-query` skill
119
+
120
+ For **Pattern 2**:
121
+
122
+ 1. Define query inline using the `gql` template tag
123
+ 2. Ensure the query name matches what codegen expects
124
+
125
+ ### Step 5: Test Queries Against Live Org
126
+
127
+ Use the testing workflows in the `generating-graphql-read-query` and `generating-graphql-mutation-query` skills to validate queries against the connected org before integrating into the app.
128
+
129
+ ### Step 6: Generate Types
130
+
131
+ ```bash
132
+ # Run from webapp dir (force-app/main/default/webapplications/<app-name>/)
133
+ npm run graphql:codegen
134
+ ```
135
+
136
+ This updates `src/api/graphql-operations-types.ts` with `<OperationName>Query`/`<OperationName>Mutation` and `<OperationName>QueryVariables`/`<OperationName>MutationVariables`.
137
+
138
+ ### Step 7: Lint Validate
139
+
140
+ Run ESLint on the file containing the query to validate it against the schema **before** any live testing:
141
+
142
+ ```bash
143
+ # Run from webapp dir
144
+ npx eslint <path-to-file>
145
+ ```
146
+
147
+ The `@graphql-eslint/eslint-plugin` processor extracts GraphQL from `gql` template literals and validates them against `schema.graphql`. Fix all ESLint errors before proceeding.
148
+
149
+ ### Step 8: Implement and Verify
150
+
151
+ Implement the data access function using the pattern below. Use the Quality Checklist before completing.
152
+
153
+ ---
154
+
155
+ ## Core Types & Function Signatures
156
+
157
+ ### createDataSDK and graphql
158
+
159
+ ```typescript
160
+ import { createDataSDK } from "@salesforce/sdk-data";
161
+
162
+ const sdk = await createDataSDK();
163
+ const response = await sdk.graphql?.<ResponseType, VariablesType>(query, variables);
164
+ ```
165
+
166
+ `createDataSDK()` returns a `DataSDK` instance. The `graphql` method uses optional chaining (`?.`) because not all surfaces support GraphQL.
167
+
168
+ ### gql Template Tag
169
+
170
+ ```typescript
171
+ import { gql } from "@salesforce/sdk-data";
172
+
173
+ const MY_QUERY = gql`
174
+ query MyQuery {
175
+ uiapi { ... }
176
+ }
177
+ `;
178
+ ```
179
+
180
+ The `gql` tag enables ESLint validation against the schema. Plain template strings bypass validation.
181
+
182
+ ### Error Handling
183
+
184
+ Default: treat any errors as failure (Strategy A). For partial data tolerance, log errors but use data. For mutations where some return fields are inaccessible, use Strategy C (fail only when no data).
185
+
186
+ ```typescript
187
+ // Default: strict
188
+ if (response?.errors?.length) {
189
+ throw new Error(response.errors.map((e) => e.message).join("; "));
190
+ }
191
+ const result = response?.data;
192
+ ```
193
+
194
+ Responses follow `uiapi.query.ObjectName.edges[].node`; fields use `{ value }`.
195
+
196
+ ### NodeOfConnection
197
+
198
+ ```typescript
199
+ import { type NodeOfConnection } from "@salesforce/sdk-data";
200
+
201
+ type AccountNode = NodeOfConnection<GetHighRevenueAccountsQuery["uiapi"]["query"]["Account"]>;
202
+ ```
203
+
204
+ ---
205
+
206
+ ## Pattern 1: External .graphql File
207
+
208
+ Create a `.graphql` file, run `npm run graphql:codegen`, import with `?raw` suffix, and use generated types.
209
+
210
+ **Required imports:**
211
+
212
+ ```typescript
213
+ import { createDataSDK, type NodeOfConnection } from "@salesforce/sdk-data";
214
+ import MY_QUERY from "./query/myQuery.graphql?raw"; // ← ?raw suffix required
215
+ import type { GetMyDataQuery, GetMyDataQueryVariables } from "../graphql-operations-types";
216
+ ```
217
+
218
+ **When to use:** Complex queries with variables, fragments, or shared across files. Does NOT support dynamic queries (field set varies at runtime).
219
+
220
+ ---
221
+
222
+ ## Pattern 2: Inline gql Tag
223
+
224
+ **Required imports:**
225
+
226
+ ```typescript
227
+ import { createDataSDK, gql } from "@salesforce/sdk-data";
228
+ import { type CurrentUserQuery } from "../graphql-operations-types";
229
+
230
+ const MY_QUERY = gql`
231
+ query CurrentUser {
232
+ uiapi { ... }
233
+ }
234
+ `;
235
+ ```
236
+
237
+ > **MUST use `gql` tag** — plain template strings bypass the `@graphql-eslint` processor entirely, meaning no lint validation against the schema.
238
+
239
+ **When to use:** Simple, colocated queries. Supports dynamic queries (field set varies at runtime).
240
+
241
+ ---
242
+
243
+ ## Conditional Field Selection
244
+
245
+ For dynamic fieldsets with **known** fields, use `@include(if: $condition)` and `@skip(if: $condition)` in `.graphql` files. See GraphQL spec for details.
246
+
247
+ ---
248
+
249
+ ## Anti-Patterns (Not Recommended)
250
+
251
+ ### Direct API Calls
252
+
253
+ ```typescript
254
+ // NOT RECOMMENDED: Direct axios/fetch calls for GraphQL
255
+ // PREFERRED: Use the Data SDK
256
+ const sdk = await createDataSDK();
257
+ const response = await sdk.graphql?.<ResponseType>(query, variables);
258
+ ```
259
+
260
+ ### Missing Type Definitions
261
+
262
+ ```typescript
263
+ // NOT RECOMMENDED: Untyped GraphQL calls
264
+ // PREFERRED: Provide response type
265
+ const response = await sdk.graphql?.<GetMyDataQuery>(query);
266
+ ```
267
+
268
+ ### Plain String Queries (Without gql Tag)
269
+
270
+ ```typescript
271
+ // NOT RECOMMENDED: Plain strings bypass ESLint validation
272
+ const query = `query { ... }`;
273
+
274
+ // PREFERRED: Use gql tag for inline queries
275
+ const QUERY = gql`query { ... }`;
276
+ ```
277
+
278
+ ---
279
+
280
+ ## Quality Checklist
281
+
282
+ > If you have not completed the workflow above, **stop and complete it first**. Invoke the skill workflow before using this checklist.
283
+
284
+ Before completing GraphQL data access code:
285
+
286
+ ### For Pattern 1 (.graphql files):
287
+
288
+ 1. [ ] All field names verified via grep against `schema.graphql` (invoke `exploring-graphql-schema`)
289
+ 2. [ ] Create `.graphql` file for the query/mutation
290
+ 3. [ ] Run `npm run graphql:codegen` to generate types
291
+ 4. [ ] Import query with `?raw` suffix
292
+ 5. [ ] Import generated types from `graphql-operations-types.ts`
293
+ 6. [ ] Use `sdk.graphql?.<ResponseType>()` with proper generic
294
+ 7. [ ] Handle `response.errors` and destructure `response.data`
295
+ 8. [ ] Use `NodeOfConnection` for cleaner node types when needed
296
+ 9. [ ] Run `npx eslint <file>` from webapp dir — fix all GraphQL errors
297
+
298
+ ### For Pattern 2 (inline with gql):
299
+
300
+ 1. [ ] All field names verified via grep against `schema.graphql`
301
+ 2. [ ] Define query using `gql` template tag (NOT a plain string)
302
+ 3. [ ] Ensure query name matches generated types in `graphql-operations-types.ts`
303
+ 4. [ ] Import generated types for the query
304
+ 5. [ ] Use `sdk.graphql?.<ResponseType>()` with proper generic
305
+ 6. [ ] Handle `response.errors` and destructure `response.data`
306
+ 7. [ ] Run `npx eslint <file>` from webapp dir — fix all GraphQL errors
307
+
308
+ ### General:
309
+
310
+ - [ ] Lint validation passes (`npx eslint <file>` reports no GraphQL errors)
311
+ - [ ] Query field names match the schema exactly (case-sensitive, confirmed via grep)
312
+ - [ ] Response type generic is provided to `sdk.graphql?.<T>()`
313
+ - [ ] Optional chaining is used for nested response data
314
+
315
+ ---
316
+
317
+ ## Reference
318
+
319
+ - Schema exploration: invoke the `exploring-graphql-schema` skill
320
+ - Read query generation: invoke the `generating-graphql-read-query` skill
321
+ - Mutation query generation: invoke the `generating-graphql-mutation-query` skill
322
+ - Shared GraphQL schema types: `shared-schema.graphqls` (in this skill directory)
323
+ - Schema download: `npm run graphql:schema` (run from webapp dir)
324
+ - Type generation: `npm run graphql:codegen` (run from webapp dir)