@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.
- package/package.json +6 -5
- package/skills/accessing-webapp-data/SKILL.md +178 -0
- package/skills/agentforce-development/SKILL.md +427 -0
- package/skills/agentforce-development/assets/README-legacy.md +89 -0
- package/skills/agentforce-development/assets/agent-spec-template.md +90 -0
- package/skills/agentforce-development/assets/agents/README.md +45 -0
- package/skills/agentforce-development/assets/agents/hello-world.agent +60 -0
- package/skills/agentforce-development/assets/agents/multi-topic.agent +105 -0
- package/skills/agentforce-development/assets/agents/production-faq.agent +101 -0
- package/skills/agentforce-development/assets/agents/production-faq.bundle-meta.xml +4 -0
- package/skills/agentforce-development/assets/agents/simple-qa.agent +72 -0
- package/skills/agentforce-development/assets/apex/models-api-queueable.cls +225 -0
- package/skills/agentforce-development/assets/bundle-meta.xml +23 -0
- package/skills/agentforce-development/assets/components/apex-action.agent +52 -0
- package/skills/agentforce-development/assets/components/error-handling.agent +58 -0
- package/skills/agentforce-development/assets/components/escalation-setup.agent +169 -0
- package/skills/agentforce-development/assets/components/flow-action.agent +66 -0
- package/skills/agentforce-development/assets/components/n-ary-conditions.agent +110 -0
- package/skills/agentforce-development/assets/components/topic-with-actions.agent +40 -0
- package/skills/agentforce-development/assets/deterministic-routing.agent +166 -0
- package/skills/agentforce-development/assets/escalation-pattern.agent +209 -0
- package/skills/agentforce-development/assets/flow-action-lookup.agent +115 -0
- package/skills/agentforce-development/assets/hub-and-spoke.agent +104 -0
- package/skills/agentforce-development/assets/invocable-apex-template.cls +187 -0
- package/skills/agentforce-development/assets/local-info-agent-annotated.agent +355 -0
- package/skills/agentforce-development/assets/metadata/basic-prompt-template.promptTemplate-meta.xml +109 -0
- package/skills/agentforce-development/assets/metadata/genai-function-apex.xml +92 -0
- package/skills/agentforce-development/assets/metadata/genai-function-flow.xml +57 -0
- package/skills/agentforce-development/assets/metadata/genai-plugin.xml +72 -0
- package/skills/agentforce-development/assets/metadata/http-callout-flow.flow-meta.xml +348 -0
- package/skills/agentforce-development/assets/metadata/record-grounded-prompt.promptTemplate-meta.xml +136 -0
- package/skills/agentforce-development/assets/minimal-starter.agent +42 -0
- package/skills/agentforce-development/assets/patterns/README.md +254 -0
- package/skills/agentforce-development/assets/patterns/action-callbacks.agent +178 -0
- package/skills/agentforce-development/assets/patterns/advanced-input-bindings.agent +141 -0
- package/skills/agentforce-development/assets/patterns/bidirectional-routing.agent +156 -0
- package/skills/agentforce-development/assets/patterns/critical-input-collection.agent +244 -0
- package/skills/agentforce-development/assets/patterns/delegation-routing.agent +89 -0
- package/skills/agentforce-development/assets/patterns/lifecycle-events.agent +127 -0
- package/skills/agentforce-development/assets/patterns/llm-controlled-actions.agent +184 -0
- package/skills/agentforce-development/assets/patterns/multi-step-workflow.agent +282 -0
- package/skills/agentforce-development/assets/patterns/open-gate-routing.agent +286 -0
- package/skills/agentforce-development/assets/patterns/procedural-instructions.agent +273 -0
- package/skills/agentforce-development/assets/patterns/prompt-template-action.agent +188 -0
- package/skills/agentforce-development/assets/patterns/system-instruction-overrides.agent +293 -0
- package/skills/agentforce-development/assets/prompt-rag-search.agent +131 -0
- package/skills/agentforce-development/assets/template-multi-topic.agent +160 -0
- package/skills/agentforce-development/assets/template-single-topic.agent +81 -0
- package/skills/agentforce-development/assets/verification-gate.agent +208 -0
- package/skills/agentforce-development/references/action-prompt-templates.md +164 -0
- package/skills/agentforce-development/references/actions-reference.md +592 -0
- package/skills/agentforce-development/references/agent-access-guide.md +72 -0
- package/skills/agentforce-development/references/agent-design-and-spec-creation.md +1010 -0
- package/skills/agentforce-development/references/agent-metadata-and-lifecycle.md +575 -0
- package/skills/agentforce-development/references/agent-script-core-language.md +1218 -0
- package/skills/agentforce-development/references/agent-topic-map-diagrams.md +323 -0
- package/skills/agentforce-development/references/agent-user-setup.md +526 -0
- package/skills/agentforce-development/references/agent-validation-and-debugging.md +803 -0
- package/skills/agentforce-development/references/known-issues.md +353 -0
- package/skills/agentforce-development/references/minimal-examples.md +67 -0
- package/skills/agentforce-development/references/production-gotchas.md +279 -0
- package/skills/agentforce-development/references/salesforce-cli-for-agents.md +393 -0
- package/skills/agentforce-development/references/version-history.md +23 -0
- package/skills/building-webapp-data-visualization/SKILL.md +72 -0
- package/skills/building-webapp-data-visualization/implementation/bar-line-chart.md +316 -0
- package/skills/building-webapp-data-visualization/implementation/dashboard-layout.md +189 -0
- package/skills/building-webapp-data-visualization/implementation/donut-chart.md +181 -0
- package/skills/building-webapp-data-visualization/implementation/stat-card.md +150 -0
- package/skills/building-webapp-react-components/SKILL.md +96 -0
- package/skills/building-webapp-react-components/implementation/component.md +78 -0
- package/skills/building-webapp-react-components/implementation/header-footer.md +132 -0
- package/skills/building-webapp-react-components/implementation/page.md +93 -0
- package/skills/configuring-webapp-csp-trusted-sites/SKILL.md +90 -0
- package/skills/configuring-webapp-csp-trusted-sites/implementation/metadata-format.md +281 -0
- package/skills/configuring-webapp-metadata/SKILL.md +158 -0
- package/skills/creating-webapp/SKILL.md +141 -0
- package/skills/deploying-webapp-to-salesforce/SKILL.md +229 -0
- package/skills/exploring-webapp-graphql-schema/SKILL.md +149 -0
- package/skills/fetching-webapp-rest-api/SKILL.md +167 -0
- package/skills/{salesforce-custom-application → generating-custom-application}/SKILL.md +2 -4
- package/skills/{salesforce-custom-field → generating-custom-field}/SKILL.md +1 -5
- package/skills/{salesforce-custom-lightning-type → generating-custom-lightning-type}/SKILL.md +36 -2
- package/skills/{salesforce-custom-object → generating-custom-object}/SKILL.md +1 -1
- package/skills/generating-custom-tab/SKILL.md +154 -0
- package/skills/generating-experience-lwr-site/SKILL.md +196 -0
- package/skills/generating-experience-lwr-site/docs/bootstrap-template-byo-lwr.md +224 -0
- package/skills/generating-experience-lwr-site/docs/configure-content-brandingSet.md +131 -0
- package/skills/generating-experience-lwr-site/docs/configure-content-route.md +232 -0
- package/skills/generating-experience-lwr-site/docs/configure-content-themeLayout.md +141 -0
- package/skills/generating-experience-lwr-site/docs/configure-content-view.md +233 -0
- package/skills/generating-experience-lwr-site/docs/configure-guest-sharing-rules.md +42 -0
- package/skills/generating-experience-lwr-site/docs/handle-component-and-region-ids.md +27 -0
- package/skills/generating-experience-lwr-site/docs/handle-ui-components.md +215 -0
- package/skills/generating-experience-react-site/SKILL.md +67 -0
- package/skills/generating-experience-react-site/docs/configure-metadata-custom-site.md +41 -0
- package/skills/generating-experience-react-site/docs/configure-metadata-digital-experience-bundle.md +17 -0
- package/skills/generating-experience-react-site/docs/configure-metadata-digital-experience-config.md +21 -0
- package/skills/generating-experience-react-site/docs/configure-metadata-digital-experience.md +38 -0
- package/skills/generating-experience-react-site/docs/configure-metadata-network.md +72 -0
- package/skills/{salesforce-flexipage → generating-flexipage}/SKILL.md +86 -9
- package/skills/{salesforce-flow → generating-flow}/SKILL.md +3 -3
- package/skills/generating-fragment/SKILL.md +117 -0
- package/skills/generating-lightning-app/SKILL.md +423 -0
- package/skills/{salesforce-list-view → generating-list-view}/SKILL.md +1 -1
- package/skills/generating-permission-set/SKILL.md +174 -0
- package/skills/{salesforce-validation-rule → generating-validation-rule}/SKILL.md +1 -1
- package/skills/generating-webapp-graphql-mutation-query/SKILL.md +258 -0
- package/skills/generating-webapp-graphql-read-query/SKILL.md +253 -0
- package/skills/implementing-webapp-file-upload/SKILL.md +396 -0
- package/skills/installing-webapp-features/SKILL.md +210 -0
- package/skills/managing-webapp-agentforce-conversation-client/SKILL.md +186 -0
- package/skills/managing-webapp-agentforce-conversation-client/references/constraints.md +134 -0
- package/skills/managing-webapp-agentforce-conversation-client/references/examples.md +132 -0
- package/skills/managing-webapp-agentforce-conversation-client/references/style-tokens.md +101 -0
- package/skills/managing-webapp-agentforce-conversation-client/references/troubleshooting.md +57 -0
- package/skills/switching-org/SKILL.md +28 -0
- package/skills/using-webapp-graphql/SKILL.md +324 -0
- package/skills/using-webapp-graphql/shared-schema.graphqls +1150 -0
- package/skills/apex-class/SKILL.md +0 -253
- package/skills/apex-class/examples/AccountDeduplicationBatch.cls +0 -148
- package/skills/apex-class/examples/AccountSelector.cls +0 -193
- package/skills/apex-class/examples/AccountService.cls +0 -201
- package/skills/apex-class/templates/abstract.cls +0 -128
- package/skills/apex-class/templates/batch.cls +0 -125
- package/skills/apex-class/templates/domain.cls +0 -102
- package/skills/apex-class/templates/dto.cls +0 -108
- package/skills/apex-class/templates/exception.cls +0 -51
- package/skills/apex-class/templates/interface.cls +0 -25
- package/skills/apex-class/templates/queueable.cls +0 -92
- package/skills/apex-class/templates/schedulable.cls +0 -75
- package/skills/apex-class/templates/selector.cls +0 -92
- package/skills/apex-class/templates/service.cls +0 -69
- package/skills/apex-class/templates/utility.cls +0 -97
- package/skills/apex-test-class/SKILL.md +0 -101
- package/skills/apex-test-class/references/assertion-patterns.md +0 -209
- package/skills/apex-test-class/references/async-testing.md +0 -276
- package/skills/apex-test-class/references/mocking-patterns.md +0 -219
- package/skills/apex-test-class/references/test-data-factory.md +0 -176
- package/skills/deployment-readiness-check/SKILL.md +0 -257
- package/skills/deployment-readiness-check/assets/deployment_checklist.md +0 -286
- package/skills/deployment-readiness-check/references/rollback_procedures.md +0 -308
- package/skills/deployment-readiness-check/scripts/check_metadata.sh +0 -207
- package/skills/salesforce-custom-tab/SKILL.md +0 -78
- package/skills/salesforce-experience-site/SKILL.md +0 -178
- package/skills/salesforce-fragment/SKILL.md +0 -42
- package/skills/salesforce-lightning-app-build/SKILL.md +0 -254
- package/skills/salesforce-web-app-creating-records/SKILL.md +0 -84
- package/skills/salesforce-web-app-feature/SKILL.md +0 -70
- package/skills/salesforce-web-app-list-and-create-records/SKILL.md +0 -36
- package/skills/salesforce-web-application/SKILL.md +0 -34
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: generating-permission-set
|
|
3
|
+
description: Generates correct, deployable Salesforce permission set metadata (PermissionSet XML) with object, field, user, and app permissions. Use this skill when creating or editing permission set metadata, object permissions, field-level security (FLS), tab visibility, or deploying permission sets.
|
|
4
|
+
compatibility: Salesforce Metadata API v60.0+
|
|
5
|
+
metadata:
|
|
6
|
+
author: afv-library
|
|
7
|
+
version: "1.0"
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## When to Use This Skill
|
|
11
|
+
|
|
12
|
+
Use when generating or editing permission set metadata, or when granting object, field, user, and app permissions.
|
|
13
|
+
|
|
14
|
+
## Step 1: Define Core Properties
|
|
15
|
+
|
|
16
|
+
Start by defining the required permission set properties:
|
|
17
|
+
|
|
18
|
+
```xml
|
|
19
|
+
<PermissionSet xmlns="http://soap.sforce.com/2006/04/metadata">
|
|
20
|
+
<fullName>YourPermissionSetName</fullName>
|
|
21
|
+
<label>Display Name for Administrators</label>
|
|
22
|
+
<description>Clear description of purpose and intended audience</description>
|
|
23
|
+
</PermissionSet>
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
**Naming conventions:**
|
|
27
|
+
- Use descriptive API names (e.g., `Sales_Manager_Access`)
|
|
28
|
+
|
|
29
|
+
## Step 2: Configure Object Permissions
|
|
30
|
+
|
|
31
|
+
Add CRUD permissions for standard and custom objects:
|
|
32
|
+
|
|
33
|
+
```xml
|
|
34
|
+
<objectPermissions>
|
|
35
|
+
<allowCreate>true</allowCreate>
|
|
36
|
+
<allowRead>true</allowRead>
|
|
37
|
+
<allowEdit>true</allowEdit>
|
|
38
|
+
<allowDelete>false</allowDelete>
|
|
39
|
+
<modifyAllRecords>false</modifyAllRecords>
|
|
40
|
+
<viewAllRecords>false</viewAllRecords>
|
|
41
|
+
<viewAllFields>false</viewAllFields>
|
|
42
|
+
<object>Account</object>
|
|
43
|
+
</objectPermissions>
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Step 3: Set Field-Level Security
|
|
47
|
+
|
|
48
|
+
Define field permissions for sensitive or custom fields:
|
|
49
|
+
|
|
50
|
+
```xml
|
|
51
|
+
<fieldPermissions>
|
|
52
|
+
<editable>true</editable>
|
|
53
|
+
<readable>true</readable>
|
|
54
|
+
<field>Account.SSN__c</field>
|
|
55
|
+
</fieldPermissions>
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
**Important:**
|
|
59
|
+
- Required fields must NEVER appear in list of field permissions. Granting field-level security on required fields is not allowed by the platform and will cause deployment failure.
|
|
60
|
+
- Before adding any field, confirm from the object metadata that the field exists and is not required
|
|
61
|
+
- A field is required when its metadata contains `<required>true</required>`:
|
|
62
|
+
- Formula fields cannot be editable
|
|
63
|
+
- Master-detail fields are required fields on the child (detail) object
|
|
64
|
+
|
|
65
|
+
```xml
|
|
66
|
+
<fields>
|
|
67
|
+
<fullName>FieldName__c</fullName>
|
|
68
|
+
<required>true</required>
|
|
69
|
+
</fields>
|
|
70
|
+
```
|
|
71
|
+
- Use format `ObjectName.FieldName` for field references
|
|
72
|
+
- Set both readable and editable to true when the user needs edit access; editable implies readable
|
|
73
|
+
- If all fields should be visible, can alternatively enable the "viewAllFields" object permission
|
|
74
|
+
|
|
75
|
+
## Step 4: Grant User Permissions
|
|
76
|
+
|
|
77
|
+
Add system-level permissions for features and capabilities:
|
|
78
|
+
|
|
79
|
+
```xml
|
|
80
|
+
<userPermissions>
|
|
81
|
+
<enabled>true</enabled>
|
|
82
|
+
<name>ApiEnabled</name>
|
|
83
|
+
</userPermissions>
|
|
84
|
+
<userPermissions>
|
|
85
|
+
<enabled>true</enabled>
|
|
86
|
+
<name>RunReports</name>
|
|
87
|
+
</userPermissions>
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
**Common permissions:**
|
|
91
|
+
- `ApiEnabled`: API access
|
|
92
|
+
- `ViewSetup`: View Setup menu
|
|
93
|
+
- `ManageUsers`: User management
|
|
94
|
+
- `RunReports`: Report execution
|
|
95
|
+
|
|
96
|
+
**Security review required for:**
|
|
97
|
+
- `ViewAllData`: Read all records
|
|
98
|
+
- `ModifyAllData`: Edit all records
|
|
99
|
+
- `ManageUsers`: User administration
|
|
100
|
+
|
|
101
|
+
## Step 5: Configure App and Tab Visibility
|
|
102
|
+
|
|
103
|
+
Make applications and tabs visible to users:
|
|
104
|
+
|
|
105
|
+
```xml
|
|
106
|
+
<applicationVisibilities>
|
|
107
|
+
<application>Sales_Console</application>
|
|
108
|
+
<visible>true</visible>
|
|
109
|
+
</applicationVisibilities>
|
|
110
|
+
<tabSettings>
|
|
111
|
+
<tab>CustomTab__c</tab>
|
|
112
|
+
<visibility>Visible</visibility>
|
|
113
|
+
</tabSettings>
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
**Application visibility options:**
|
|
117
|
+
- <visible> can be true or false
|
|
118
|
+
|
|
119
|
+
**Tab visibility options:**
|
|
120
|
+
- `Visible`: The tab is available on the All Tabs page and appears in the visible tabs for its associated app. Can be customized.
|
|
121
|
+
- `Available`: The tab is available on the All Tabs page. Individual users can customize their display to make the tab visible in any app
|
|
122
|
+
- `None`: Not visible
|
|
123
|
+
|
|
124
|
+
**CRITICAL - Tab Naming:**
|
|
125
|
+
- Custom object tabs: MUST include the __c suffix (e.g., MyCustomObject__c)
|
|
126
|
+
- Standard object tabs: Use the object name with "standard-" prefix (e.g., standard-Account, standard-Contact)
|
|
127
|
+
- The tab name matches the object's API name exactly
|
|
128
|
+
|
|
129
|
+
## Step 6: Add Apex and Visualforce Access (Optional)
|
|
130
|
+
|
|
131
|
+
Grant access to custom code:
|
|
132
|
+
|
|
133
|
+
```xml
|
|
134
|
+
<classAccesses>
|
|
135
|
+
<apexClass>CustomController</apexClass>
|
|
136
|
+
<enabled>true</enabled>
|
|
137
|
+
</classAccesses>
|
|
138
|
+
<pageAccesses>
|
|
139
|
+
<apexPage>CustomPage</apexPage>
|
|
140
|
+
<enabled>true</enabled>
|
|
141
|
+
</pageAccesses>
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
## Step 7: Set License and Record Type Settings (Optional)
|
|
145
|
+
|
|
146
|
+
Specify license requirements and record type visibility:
|
|
147
|
+
|
|
148
|
+
```xml
|
|
149
|
+
<license>Salesforce</license>
|
|
150
|
+
<hasActivationRequired>false</hasActivationRequired>
|
|
151
|
+
<recordTypeVisibilities>
|
|
152
|
+
<recordType>Account.Business</recordType>
|
|
153
|
+
<visible>true</visible>
|
|
154
|
+
<default>true</default>
|
|
155
|
+
</recordTypeVisibilities>
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## Validation Checklist
|
|
159
|
+
|
|
160
|
+
Before deploying, verify:
|
|
161
|
+
- [ ] fullName, label, description set
|
|
162
|
+
- [ ] Permissions follow least privilege
|
|
163
|
+
- [ ] No required fields in `<fieldPermissions>`
|
|
164
|
+
- [ ] No duplicate permissions
|
|
165
|
+
- [ ] no lengthy comments
|
|
166
|
+
|
|
167
|
+
## What Causes Deployment Failure
|
|
168
|
+
|
|
169
|
+
- **Field permissions on required fields:** Any required field in `<fieldPermissions>` fails deployment. Required fields cannot have FLS; omit them entirely. Always confirm from object/field metadata that a field exists and is not required—never assume.
|
|
170
|
+
- **Incorrect API names:** Using the wrong name or missing suffixes (e.g. missing `__c` for custom objects, fields, tabs) cause failure.
|
|
171
|
+
|
|
172
|
+
## Deployment
|
|
173
|
+
|
|
174
|
+
Deploy using Salesforce CLI
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
-
name:
|
|
2
|
+
name: generating-validation-rule
|
|
3
3
|
description: Use this skill when users need to create, modify, or validate Salesforce Validation Rules. Trigger when users mention validation rules, field validation, data quality rules, formula validation, error messages, or validation logic. Also use when users encounter validation errors, need to update formulas, or want to enforce business rules at the data layer. Always use this skill for any validation rule work.
|
|
4
4
|
---
|
|
5
5
|
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: generating-webapp-graphql-mutation-query
|
|
3
|
+
description: Generate Salesforce GraphQL mutation queries. Use when the query to generate is a mutation query. Schema exploration must complete first — invoke exploring-graphql-schema first.
|
|
4
|
+
paths:
|
|
5
|
+
- "**/*.ts"
|
|
6
|
+
- "**/*.tsx"
|
|
7
|
+
- "**/*.graphql"
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# Salesforce GraphQL Mutation Query Generation
|
|
11
|
+
|
|
12
|
+
**Triggering conditions**
|
|
13
|
+
|
|
14
|
+
1. Only if the schema exploration phase completed successfully (invoke `exploring-graphql-schema` first)
|
|
15
|
+
2. Only if the query to generate is a mutation query
|
|
16
|
+
|
|
17
|
+
## Schema Access Policy
|
|
18
|
+
|
|
19
|
+
> ⚠️ **GREP ONLY** — During mutation generation you may need to verify field names, input types, or representations. 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.
|
|
20
|
+
|
|
21
|
+
## Your Role
|
|
22
|
+
|
|
23
|
+
You are a GraphQL expert. Generate Salesforce-compatible mutation queries. Schema exploration must complete first. If the schema exploration has not been executed yet, you **MUST** run the full exploration workflow from the `exploring-graphql-schema` skill first, then return here for mutation query generation.
|
|
24
|
+
|
|
25
|
+
## Mutation Queries General Information
|
|
26
|
+
|
|
27
|
+
The GraphQL engine supports `Create`, `Update`, and `Delete` operations. `Update` and `Delete` operate on Id-based entity identification. See the [mutation query schema](#mutation-query-schema) section.
|
|
28
|
+
|
|
29
|
+
## Mutation Query Generation Workflow
|
|
30
|
+
|
|
31
|
+
Strictly follow the rules below when generating the GraphQL mutation query:
|
|
32
|
+
|
|
33
|
+
1. **Input Fields Validation** - Validate that the set of fields validate [input field constraints](#mutation-queries-input-field-constraints). Verify every field name and type against grep output from the schema — do NOT guess or assume
|
|
34
|
+
2. **Output Fields Validation** - Validate that the set of fields used in the select part of the query validate the [output fields constraints](#mutation-queries-output-field-constraints)
|
|
35
|
+
3. **Type Consistency** - Make sure variables used as query arguments and their related fields share the same GraphQL type. Verify types via grep lookup — do NOT assume types
|
|
36
|
+
4. **Report Phase** - Use the [Mutation Query Report Template](#mutation-query-report-template) below to report on the previous validation phases
|
|
37
|
+
5. **Input Arguments** - `input` is the default name for the argument, unless otherwise specified
|
|
38
|
+
6. **Output Field** - For `Create` and `Update` operations, the output field is always named `Record`, and is of type EntityName
|
|
39
|
+
7. **Field Name Validation** - Every field name in the generated mutation **MUST** match a field confirmed via grep lookup in the schema. Do NOT guess or assume field names exist
|
|
40
|
+
8. **Query Generation** - Use the [mutation query](#mutation-query-templates) template and adjust it based on the selected operation
|
|
41
|
+
9. **Output Format** - Use the [standalone](#mutation-standalone-default-output-format---clean-code-only)
|
|
42
|
+
10. **Lint Validation** - After writing the mutation to a file, run `npx eslint <file>` from the webapp dir to validate it against the schema. Fix any reported errors before proceeding. See [Lint Validation](#lint-validation) for details
|
|
43
|
+
11. **Test the Query** - Use the [Generated Mutation Query Testing](#generated-mutation-query-testing) workflow to test the generated query
|
|
44
|
+
1. **Report First** - Always output the generated mutation in the proper output format BEFORE initiating any test
|
|
45
|
+
|
|
46
|
+
## Mutation Query Schema
|
|
47
|
+
|
|
48
|
+
**Important**: In the schema fragments below, replace **EntityName** occurrences by the real entity name (i.e. Account, Case...).
|
|
49
|
+
**Important**: `Delete` operations all share the same generic `Record` entity name for both input and payload, only exposing the standard `Id` field.
|
|
50
|
+
|
|
51
|
+
```graphql
|
|
52
|
+
input EntityNameCreateRepresentation {
|
|
53
|
+
# Subset of EntityName fields here
|
|
54
|
+
}
|
|
55
|
+
input EntityNameCreateInput { EntityName: EntityNameCreateRepresentation! }
|
|
56
|
+
type EntityNameCreatePayload { Record: EntityName! }
|
|
57
|
+
|
|
58
|
+
input EntityNameUpdateRepresentation {
|
|
59
|
+
# Subset of EntityName fields here
|
|
60
|
+
}
|
|
61
|
+
input EntityNameUpdateInput { Id: IdOrRef! EntityName: EntityNameUpdateRepresentation! }
|
|
62
|
+
type EntityNameUpdatePayload { Record: EntityName! }
|
|
63
|
+
|
|
64
|
+
input RecordDeleteInput { Id: IdOrRef! }
|
|
65
|
+
type RecordDeletePayload { Id: ID }
|
|
66
|
+
|
|
67
|
+
type UIAPIMutations {
|
|
68
|
+
EntityNameCreate(input: EntityNameCreateInput!): EntityNameCreatePayload
|
|
69
|
+
EntityNameDelete(input: RecordDeleteInput!): RecordDeletePayload
|
|
70
|
+
EntityNameUpdate(input: EntityNameUpdateInput!): EntityNameUpdatePayload
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Mutation Queries Input Field Constraints
|
|
75
|
+
|
|
76
|
+
1. **`Create` Mutation Queries**:
|
|
77
|
+
1. **MUST** include all required fields
|
|
78
|
+
2. **MUST** only include createable fields
|
|
79
|
+
3. Child relationships can't be set and **MUST** be excluded
|
|
80
|
+
4. Fields with type `REFERENCE` can only be assigned IDs through their `ApiName` name
|
|
81
|
+
2. **`Update` Mutation Queries**:
|
|
82
|
+
1. **MUST** include the id of the entity to update
|
|
83
|
+
2. **MUST** only include updateable fields
|
|
84
|
+
3. Child relationships can't be set and **MUST** be excluded
|
|
85
|
+
4. Fields with type `REFERENCE` can only be assigned IDs through their `ApiName` name
|
|
86
|
+
3. **`Delete` Mutation Queries**:
|
|
87
|
+
1. **MUST** include the id of the entity to delete
|
|
88
|
+
|
|
89
|
+
## Mutation Queries Output Field Constraints
|
|
90
|
+
|
|
91
|
+
1. **`Create` and `Update` Mutation Queries**:
|
|
92
|
+
1. **MUST** exclude all child relationships
|
|
93
|
+
2. **MUST** exclude all `REFERENCE` fields, unless accessed through their `ApiName` member (no navigation to referenced entity)
|
|
94
|
+
3. Inaccessible fields will be reported as part of the `errors` attribute in the returned payload
|
|
95
|
+
4. Child relationships **CAN'T** be queried as part of a mutation
|
|
96
|
+
5. Fields with type `REFERENCE` can only be queried through their `ApiName` (no referenced entities navigation, no sub fields)
|
|
97
|
+
2. **`Delete` Mutation Queries**:
|
|
98
|
+
1. **MUST** only include the `Id` field
|
|
99
|
+
|
|
100
|
+
## Mutation Query Report Template
|
|
101
|
+
|
|
102
|
+
Input arguments:
|
|
103
|
+
|
|
104
|
+
- Required fields: FieldName1 (Type1), FieldName2 (Type2)...
|
|
105
|
+
- Other fields: FieldName3 (Type3)...
|
|
106
|
+
Output fields: FieldNameA (TypeA), FieldNameB (TypeB)...
|
|
107
|
+
|
|
108
|
+
## Mutation Query Templates
|
|
109
|
+
|
|
110
|
+
```graphql
|
|
111
|
+
mutation mutateEntityName(
|
|
112
|
+
# arguments
|
|
113
|
+
) {
|
|
114
|
+
uiapi {
|
|
115
|
+
EntityNameOperation(input: {
|
|
116
|
+
# the following is for `Create` and `Update` operations only
|
|
117
|
+
EntityName: {
|
|
118
|
+
# Input fields
|
|
119
|
+
}
|
|
120
|
+
# the following is for `Update` and `Delete` operations only
|
|
121
|
+
Id: ... # id here
|
|
122
|
+
}) {
|
|
123
|
+
# the following is for `Create` and `Update` operations only
|
|
124
|
+
Record {
|
|
125
|
+
# Output fields
|
|
126
|
+
}
|
|
127
|
+
# the following is for `Delete` operations only
|
|
128
|
+
Id: ... # id here
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
## Mutation Standalone (Default) Output Format - CLEAN CODE ONLY
|
|
135
|
+
|
|
136
|
+
```javascript
|
|
137
|
+
import { gql } from '@salesforce/sdk-data';
|
|
138
|
+
const QUERY_NAME = gql`
|
|
139
|
+
mutation mutateEntity($input: EntityNameOperationInput!) {
|
|
140
|
+
uiapi {
|
|
141
|
+
EntityNameOperation(input: $input) {
|
|
142
|
+
# select output fields here depending on operation type
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
`;
|
|
147
|
+
|
|
148
|
+
const QUERY_VARIABLES = {
|
|
149
|
+
input: {
|
|
150
|
+
// The following is for `Create` and `Update` operations only
|
|
151
|
+
EntityName: {
|
|
152
|
+
// variables here
|
|
153
|
+
},
|
|
154
|
+
// The following is for `Update` and `Delete` operations only
|
|
155
|
+
Id: ... // id here
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
**❌ FORBIDDEN — Do NOT include any of the following:**
|
|
161
|
+
|
|
162
|
+
- Explanatory comments about the query (inline or surrounding)
|
|
163
|
+
- Field descriptions or annotations
|
|
164
|
+
- Additional text about what the query does
|
|
165
|
+
- Workflow step descriptions or summaries
|
|
166
|
+
- Comments like `// fetches...`, `// creates...`, `/* ... */`
|
|
167
|
+
|
|
168
|
+
**✅ ONLY output:**
|
|
169
|
+
|
|
170
|
+
- The raw query string constant (using `gql` tagged template)
|
|
171
|
+
- The variables object constant
|
|
172
|
+
- Nothing else — no extra imports, no exports, no wrapper functions
|
|
173
|
+
|
|
174
|
+
## Lint Validation
|
|
175
|
+
|
|
176
|
+
After writing the generated mutation into a source file, validate it against the schema using the project's GraphQL ESLint setup:
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
# Run from webapp dir (force-app/main/default/webapplications/<app-name>/)
|
|
180
|
+
npx eslint <path-to-file-containing-mutation>
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
**How it works:** The ESLint config uses `@graphql-eslint/eslint-plugin` with its `processor`, which extracts GraphQL operations from `gql` template literals in `.ts`/`.tsx` files and validates the extracted `.graphql` virtual files against `schema.graphql`.
|
|
184
|
+
|
|
185
|
+
**Rules enforced:** `no-anonymous-operations`, `no-duplicate-fields`, `known-fragment-names`, `no-undefined-variables`, `no-unused-variables`
|
|
186
|
+
|
|
187
|
+
**On failure:** Fix the reported issues, re-run `npx eslint <file>` until clean, then proceed to testing.
|
|
188
|
+
|
|
189
|
+
> ⚠️ **Prerequisites**: The `schema.graphql` file must exist (invoke `exploring-graphql-schema` first) and project dependencies must be installed (`npm install`).
|
|
190
|
+
|
|
191
|
+
## Generated Mutation Query Testing
|
|
192
|
+
|
|
193
|
+
**Triggering conditions** — **ALL conditions must be true:**
|
|
194
|
+
|
|
195
|
+
1. The [Mutation Query Generation Workflow](#mutation-query-generation-workflow) completed with status `SUCCESS` and you have a generated query
|
|
196
|
+
2. The query is a mutation query
|
|
197
|
+
3. A non-manual method was used during schema exploration to retrieve introspection data
|
|
198
|
+
|
|
199
|
+
**Workflow**
|
|
200
|
+
|
|
201
|
+
1. **Report Step** - State the exact method you will use to test (e.g., `sf api request graphql` from the **project root**, Connect API, etc.) — this **MUST** match the method used during schema exploration
|
|
202
|
+
2. **Interactive Step** - Ask the user whether they want you to test the query using the proposed method
|
|
203
|
+
1. **STOP and WAIT** for the user's answer. Do NOT proceed until the user responds. Do NOT assume consent.
|
|
204
|
+
3. **Input Arguments** - You **MUST** ask the user for the input argument values to use in the test
|
|
205
|
+
1. **STOP and WAIT** for the user's answer. Do NOT proceed until the user provides values. Do NOT fabricate test data.
|
|
206
|
+
4. **Test Query** - Only if the user explicitly agrees and has provided input values:
|
|
207
|
+
1. Execute the mutation using the reported method (e.g., `sf api request rest` to POST the query and variables to the GraphQL endpoint):
|
|
208
|
+
```bash
|
|
209
|
+
sf api request rest /services/data/v65.0/graphql \
|
|
210
|
+
--method POST \
|
|
211
|
+
--body '{"query":"mutation mutateEntity($input: EntityNameOperationInput!) { uiapi { EntityNameOperation(input: $input) { Record { Id } } } }","variables":{"input":{"EntityName":{"Field":"Value"}}}}'
|
|
212
|
+
```
|
|
213
|
+
2. Replace `v65.0` with the API version of the target org
|
|
214
|
+
3. Replace the `query` value with the generated mutation query string
|
|
215
|
+
4. Replace the `variables` value with the user-provided input arguments
|
|
216
|
+
5. **Result Analysis** - Retrieve the `data` and `errors` attributes from the returned payload, and report the result of the test as one of the following options:
|
|
217
|
+
1. `PARTIAL` if `data` is not an empty object, but `errors` is not an empty list - Explanation: some of the queried fields are not accessible on mutations
|
|
218
|
+
2. `FAILED` if `data` is an empty object - Explanation: the query is not valid
|
|
219
|
+
3. `SUCCESS` if `errors` is an empty list
|
|
220
|
+
6. **Remediation Step** - If status is not `SUCCESS`, use the [`FAILED`](#failed-status-handling-workflow) or [`PARTIAL`](#partial-status-handling-workflow) status handling workflows
|
|
221
|
+
|
|
222
|
+
### `FAILED` Status Handling Workflow
|
|
223
|
+
|
|
224
|
+
The query is invalid:
|
|
225
|
+
|
|
226
|
+
1. **Error Analysis** - Parse and categorize the specific error messages
|
|
227
|
+
2. **Root Cause Identification** - Use error message to identify the root cause:
|
|
228
|
+
- **Execution** - Error contains `invalid cross reference id` or `entity is deleted`
|
|
229
|
+
- **Syntax** - Error contains `invalid syntax`
|
|
230
|
+
- **Validation** - Error contains `validation error`
|
|
231
|
+
- **Type** - Error contains `VariableTypeMismatch` or `UnknownType`
|
|
232
|
+
- **Navigation** - Error contains `is not currently available in mutation results`
|
|
233
|
+
- **API Version** - Query deals with updates, you're testing with Connect API and error contains `Cannot invoke JsonElement.isJsonObject()`
|
|
234
|
+
3. **Targeted Resolution** - Depending on the root cause categorization
|
|
235
|
+
- **Execution** - You're trying to update or delete an unknown/no longer available entity: either create an entity first, if you have generated the related query, or ask for a valid entity id to use. **STOP and WAIT** for the user to provide a valid Id
|
|
236
|
+
- **Syntax** - Update the query using the error message information to fix the syntax errors
|
|
237
|
+
- **Validation** - The field name is most probably invalid. Re-run the relevant grep command from the `exploring-graphql-schema` skill to verify the correct field name. If still unclear, ask the user for clarification and **STOP and WAIT** for their answer
|
|
238
|
+
- **Type** - Use the error details and re-verify the type via grep lookup in the schema. Correct the argument type and adjust variables accordingly
|
|
239
|
+
- **Navigation** - Use the [`PARTIAL` status handling workflow](#partial-status-handling-workflow) below
|
|
240
|
+
- **API Version** - `Record` selection is only available with API version 64 and higher, **report** the issue, and try again with API version 64
|
|
241
|
+
4. **Test Again** - Resume the [query testing workflow](#generated-mutation-query-testing) with the updated query (increment and track attempt counter)
|
|
242
|
+
5. **Escalation Path** - If targeted resolution fails after 2 attempts, ask for additional details and restart the entire GraphQL workflow from the `exploring-graphql-schema` skill
|
|
243
|
+
|
|
244
|
+
### `PARTIAL` Status Handling Workflow
|
|
245
|
+
|
|
246
|
+
The query can be improved:
|
|
247
|
+
|
|
248
|
+
1. Report the fields mentioned in the `errors` list
|
|
249
|
+
2. Explain that these fields can't be queried as part of a mutation query
|
|
250
|
+
3. Explain that the query might be considered as failing, as it will report errors
|
|
251
|
+
4. Offer to remove the offending fields
|
|
252
|
+
5. **STOP and WAIT** for the user's answer. Do NOT remove fields without explicit consent.
|
|
253
|
+
6. If they are OK with removing the fields restart the [generation workflow](#mutation-query-generation-workflow) with the new field list
|
|
254
|
+
|
|
255
|
+
## Related Skills
|
|
256
|
+
|
|
257
|
+
- Schema exploration: `exploring-graphql-schema` (must complete first)
|
|
258
|
+
- Read query generation: `generating-graphql-read-query`
|