@salesforce/afv-skills 1.3.0 → 1.4.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 (33) hide show
  1. package/package.json +3 -3
  2. package/skills/building-webapp-data-visualization/SKILL.md +1 -1
  3. package/skills/building-webapp-react-components/SKILL.md +1 -1
  4. package/skills/configuring-webapp-csp-trusted-sites/SKILL.md +1 -1
  5. package/skills/configuring-webapp-metadata/SKILL.md +2 -2
  6. package/skills/creating-webapp/SKILL.md +2 -3
  7. package/skills/deploying-webapp-to-salesforce/SKILL.md +2 -5
  8. package/skills/generating-custom-application/SKILL.md +1 -1
  9. package/skills/generating-custom-field/SKILL.md +1 -1
  10. package/skills/generating-custom-lightning-type/SKILL.md +1 -1
  11. package/skills/generating-custom-object/SKILL.md +1 -1
  12. package/skills/generating-custom-tab/SKILL.md +1 -1
  13. package/skills/generating-experience-lwr-site/SKILL.md +1 -1
  14. package/skills/generating-experience-react-site/SKILL.md +1 -1
  15. package/skills/generating-flexipage/SKILL.md +1 -1
  16. package/skills/generating-flow/SKILL.md +1 -1
  17. package/skills/generating-fragment/SKILL.md +1 -1
  18. package/skills/generating-list-view/SKILL.md +1 -1
  19. package/skills/generating-permission-set/SKILL.md +1 -1
  20. package/skills/generating-validation-rule/SKILL.md +1 -1
  21. package/skills/implementing-webapp-file-upload/SKILL.md +1 -1
  22. package/skills/installing-webapp-features/SKILL.md +1 -1
  23. package/skills/managing-webapp-agentforce-conversation-client/SKILL.md +1 -1
  24. package/skills/trigger-refactor-pipeline/SKILL.md +1 -1
  25. package/skills/using-webapp-salesforce-data/SKILL.md +363 -0
  26. package/skills/using-webapp-salesforce-data/graphql-search.sh +139 -0
  27. package/skills/accessing-webapp-data/SKILL.md +0 -178
  28. package/skills/exploring-webapp-graphql-schema/SKILL.md +0 -149
  29. package/skills/fetching-webapp-rest-api/SKILL.md +0 -167
  30. package/skills/generating-webapp-graphql-mutation-query/SKILL.md +0 -258
  31. package/skills/generating-webapp-graphql-read-query/SKILL.md +0 -253
  32. package/skills/using-webapp-graphql/SKILL.md +0 -324
  33. package/skills/using-webapp-graphql/shared-schema.graphqls +0 -1150
@@ -1,258 +0,0 @@
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`
@@ -1,253 +0,0 @@
1
- ---
2
- name: generating-webapp-graphql-read-query
3
- description: Generate Salesforce GraphQL read queries. Use when the query to generate is a read query. Schema exploration must complete first — invoke exploring-graphql-schema first.
4
- paths:
5
- - "**/*.ts"
6
- - "**/*.tsx"
7
- - "**/*.graphql"
8
- ---
9
-
10
- # Salesforce GraphQL Read 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 read query
16
-
17
- ## Schema Access Policy
18
-
19
- > ⚠️ **GREP ONLY** — During query generation you may need to verify field names, types, or relationships. 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
- ## Field-Level Security and @optional
22
-
23
- Field-level security (FLS) restricts which fields different users can see. Use the `@optional` directive on Salesforce record fields when possible. The server omits the field when the user lacks access, allowing the query to succeed instead of failing. Apply `@optional` to scalar fields, value-type fields (e.g. `Name { value }`), parent relationships, and child relationships. Available in API v65.0+.
24
-
25
- **Consuming code must defend against missing fields.** When a field is omitted due to FLS, it will be `undefined` (or absent) in the response. Use optional chaining (`?.`), nullish coalescing (`??`), and explicit null/undefined checks when reading query results. Never assume an optional field is present — otherwise the app may crash or behave incorrectly for users without field access.
26
-
27
- ```ts
28
- // ✅ Defend against missing fields
29
- const name = node.Name?.value ?? '';
30
- const relatedName = node.RelationshipName?.Name?.value ?? 'N/A';
31
-
32
- // ❌ Unsafe — will throw if field omitted due to FLS
33
- const name = node.Name.value;
34
- ```
35
-
36
- ## Your Role
37
-
38
- You are a GraphQL expert. Generate Salesforce-compatible read 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 read query generation.
39
-
40
- ## Read Query Generation Workflow
41
-
42
- Strictly follow the rules below when generating the GraphQL read query:
43
-
44
- 1. **No Proliferation** - Only generate for the explicitly requested fields, nothing else. Do NOT add fields the user did not ask for.
45
- 2. **Unique Query** - Leverage child relationships to query entities in one single query
46
- 3. **Navigate Entities** - Always use `relationshipName` to access reference fields and child entities
47
- 1. **Exception** - if the `relationshipName` field is null, you can't navigate the related entity, and will have to return the `Id` itself
48
- 4. **Leverage Fragments** - Generate one fragment per possible type on polymorphic fields (field with `dataType="REFERENCE"` and more than one entry in `referenceToInfos` introspection attribute)
49
- 5. **Type Consistency** - Make sure variables used as query arguments and their related fields share the same GraphQL type. Verify types against grep output from the schema — do not assume types
50
- 6. **Type Enforcement** - Make sure to leverage field type information from introspection and GraphQL schema to generate field access
51
- 7. **Field Name Validation** - Every field name in the generated query **MUST** match a field confirmed via grep lookup in the schema. Do NOT guess or assume field names exist
52
- 8. **@optional for FLS** - Apply `@optional` on all Salesforce record fields when possible (see [Field-Level Security and @optional](#field-level-security-and-optional)). This lets the query succeed when the user lacks field-level access; the server omits inaccessible fields instead of failing
53
- 9. **Consuming code defense** - When generating or modifying code that consumes read query results, defend against missing fields (see [Field-Level Security and @optional](#field-level-security-and-optional)). Use optional chaining, nullish coalescing, and null/undefined checks — never assume optional fields are present
54
- 10. **Semi and anti joins** - Use the semi-join or anti-join templates to filter an entity with conditions on child entities
55
- 11. **Query Generation** - Use the [template](#read-query-template) to generate the query
56
- 12. **Output Format** - Use the [standalone](#read-standalone-default-output-format---clean-code-only)
57
- 13. **Lint Validation** - After writing the query 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
58
- 14. **Test the Query** - Use the [Generated Read Query Testing](#generated-read-query-testing) workflow to test the generated query
59
- 1. **Report First** - Always output the generated query in the proper output format BEFORE initiating any test
60
-
61
- ## Read Query Template
62
-
63
- ```graphql
64
- query QueryName {
65
- uiapi {
66
- query {
67
- EntityName(
68
- # conditions here
69
- ) {
70
- edges {
71
- node {
72
- # Direct fields — use @optional for FLS resilience
73
- FieldName @optional { value }
74
-
75
- # Non-polymorphic reference (single type)
76
- RelationshipName @optional {
77
- Id
78
- Name { value }
79
- }
80
-
81
- # Polymorphic reference (multiple types)
82
- PolymorphicRelationshipName @optional {
83
- ...TypeAInfo
84
- ...TypeBInfo
85
- }
86
-
87
- # Child relationship (subquery)
88
- RelationshipName @optional (
89
- # conditions here
90
- ) {
91
- edges {
92
- node {
93
- # fields
94
- }
95
- }
96
- }
97
- }
98
- }
99
- }
100
- }
101
- }
102
- }
103
-
104
- fragment TypeAInfo on TypeA {
105
- Id
106
- SpecificFieldA @optional { value }
107
- }
108
-
109
- fragment TypeBInfo on TypeB {
110
- Id
111
- SpecificFieldB @optional { value }
112
- }
113
- ```
114
-
115
- ## Semi-Join and Anti-Join Condition Template
116
-
117
- Semi-joins (resp. anti-joins) condition leverage parent-child relationships and allow filtering the parent entity using a condition on child entities.
118
- This is a standard `where` condition, on the parent entity's `Id`, expressed using the `inq` (resp. `ninq`, i.e. not `inq`) operator. This operator accepts two attributes:
119
-
120
- - The child entity camelcase name to apply the condition on, with a value expressing the condition
121
- - The field name on the child entity containing the parent entity `Id`, which is the `fieldName` from the `childRelationships` information for the child entity
122
- - If the only condition is related child entity existence, you can use an `Id: { ne: null }` condition
123
-
124
- ### Semi-Join Example - ParentEntity with at least one Matching ChildEntity
125
-
126
- ```graphql
127
- query testSemiJoin {
128
- uiapi {
129
- query {
130
- ParentEntity(
131
- where: {
132
- Id: {
133
- inq: {
134
- ChildEntity: {
135
- # standard conditions here
136
- Name: { like: "test%" }
137
- Type: { eq: "some value" }
138
- }
139
- ApiName: "parentIdFieldInChild"
140
- }
141
- }
142
- }
143
- ) {
144
- edges {
145
- node {
146
- Id
147
- Name @optional {
148
- value
149
- }
150
- }
151
- }
152
- }
153
- }
154
- }
155
- }
156
- ```
157
-
158
- ### Anti-Join Example - ParentEntity with no Matching ChildEntity
159
-
160
- Same example as the [Semi-Join Example](#semi-join-example---parententity-with-at-least-one-matching-childentity), but replacing the `inq` operator by the `ninq` one.
161
-
162
- ## Read Standalone (Default) Output Format - CLEAN CODE ONLY
163
-
164
- ```javascript
165
- const QUERY_NAME = `
166
- query GetData {
167
- # query here
168
- }
169
- `;
170
-
171
- const QUERY_VARIABLES = {
172
- // variables here
173
- };
174
- ```
175
-
176
- **❌ FORBIDDEN — Do NOT include any of the following:**
177
-
178
- - Explanatory comments about the query (inline or surrounding)
179
- - Field descriptions or annotations
180
- - Additional text about what the query does
181
- - Workflow step descriptions or summaries
182
- - Comments like `// fetches...`, `// returns...`, `/* ... */`
183
-
184
- **✅ ONLY output:**
185
-
186
- - The raw query string constant
187
- - The variables object constant
188
- - Nothing else — no imports, no exports, no wrapper functions
189
-
190
- ## Lint Validation
191
-
192
- After writing the generated query into a source file, validate it against the schema using the project's GraphQL ESLint setup:
193
-
194
- ```bash
195
- # Run from webapp dir (force-app/main/default/webapplications/<app-name>/)
196
- npx eslint <path-to-file-containing-query>
197
- ```
198
-
199
- **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`.
200
-
201
- **Rules enforced:** `no-anonymous-operations`, `no-duplicate-fields`, `known-fragment-names`, `no-undefined-variables`, `no-unused-variables`
202
-
203
- **On failure:** Fix the reported issues, re-run `npx eslint <file>` until clean, then proceed to testing.
204
-
205
- > ⚠️ **Prerequisites**: The `schema.graphql` file must exist (invoke `exploring-graphql-schema` first) and project dependencies must be installed (`npm install`).
206
-
207
- ## Generated Read Query Testing
208
-
209
- **Triggering conditions** — **ALL conditions must be true:**
210
-
211
- 1. The [Read Query Generation Workflow](#read-query-generation-workflow) completed with status `SUCCESS` and you have a generated query
212
- 2. The query is a read query
213
- 3. A non-manual method was used during schema exploration to retrieve introspection data
214
-
215
- **Workflow**
216
-
217
- 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
218
- 2. **Interactive Step** - Ask the user whether they want you to test the query using the proposed method
219
- 1. **STOP and WAIT** for the user's answer. Do NOT proceed until the user responds. Do NOT assume consent.
220
- 3. **Test Query** - Only if the user explicitly agrees:
221
- 1. Use `sf api request rest` to POST the query to the GraphQL endpoint:
222
- ```bash
223
- sf api request rest /services/data/v65.0/graphql \
224
- --method POST \
225
- --body '{"query":"query GetData { uiapi { query { EntityName { edges { node { Id } } } } } }"}'
226
- ```
227
- 2. Replace `v65.0` with the API version of the target org
228
- 3. Replace the `query` value with the generated read query string
229
- 4. If the query uses variables, include them in the JSON body as a `variables` key
230
- 5. Report the result as `SUCCESS` if the query executed without error, or `FAILED` if errors were returned
231
- 6. An empty result set with no errors is `SUCCESS` — the query is valid, the org simply has no matching data
232
- 4. **Remediation Step** - If status is `FAILED`, use the [`FAILED` status handling workflows](#failed-status-handling-workflow)
233
-
234
- ### `FAILED` Status Handling Workflow
235
-
236
- The query is invalid:
237
-
238
- 1. **Error Analysis** - Parse and categorize the specific error messages
239
- 2. **Root Cause Identification** - Use error message to identify the root cause:
240
- - **Syntax** - Error contains `invalid syntax`
241
- - **Validation** - Error contains `validation error`
242
- - **Type** - Error contains `VariableTypeMismatch` or `UnknownType`
243
- 3. **Targeted Resolution** - Depending on the root cause categorization
244
- - **Syntax** - Update the query using the error message information to fix the syntax errors
245
- - **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
246
- - **Type** - Use the error details and re-verify the type via grep lookup in the schema. Correct the argument type and adjust variables accordingly
247
- 4. **Test Again** - Resume the [query testing workflow](#generated-read-query-testing) with the updated query (increment and track attempt counter)
248
- 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
249
-
250
- ## Related Skills
251
-
252
- - Schema exploration: `exploring-graphql-schema` (must complete first)
253
- - Mutation generation: `generating-graphql-mutation-query`