@salesforce/afv-skills 1.6.5 → 1.6.7
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 +3 -3
- package/skills/building-ui-bundle-app/SKILL.md +1 -1
- package/skills/building-ui-bundle-frontend/SKILL.md +3 -1
- package/skills/deploying-ui-bundle/SKILL.md +1 -1
- package/skills/generating-experience-lwr-site/SKILL.md +11 -1
- package/skills/generating-experience-lwr-site/docs/update-site-urls.md +100 -0
- package/skills/generating-ui-bundle-features/SKILL.md +1 -1
- package/skills/generating-ui-bundle-metadata/SKILL.md +9 -2
- package/skills/generating-ui-bundle-site/SKILL.md +14 -2
- package/skills/generating-ui-bundle-site/docs/configure-metadata-digital-experience.md +4 -2
- package/skills/generating-ui-bundle-site/docs/update-site-urls.md +100 -0
- package/skills/implementing-ui-bundle-agentforce-conversation-client/SKILL.md +216 -37
- package/skills/implementing-ui-bundle-agentforce-conversation-client/references/style-tokens.md +168 -21
- package/skills/implementing-ui-bundle-file-upload/SKILL.md +1 -1
- package/skills/searching-media/SKILL.md +1 -1
- package/skills/using-ui-bundle-salesforce-data/SKILL.md +338 -92
- package/skills/using-ui-bundle-salesforce-data/references/mutation-query-generation.md +0 -140
- package/skills/using-ui-bundle-salesforce-data/references/query-testing.md +0 -78
- package/skills/using-ui-bundle-salesforce-data/references/read-query-generation.md +0 -307
- package/skills/using-ui-bundle-salesforce-data/references/schema-introspection.md +0 -53
- package/skills/using-ui-bundle-salesforce-data/references/ui-bundle-integration.md +0 -221
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
# Mutation Query Generation
|
|
2
|
-
|
|
3
|
-
## Mutation Types
|
|
4
|
-
|
|
5
|
-
The GraphQL engine supports three mutation operations:
|
|
6
|
-
|
|
7
|
-
- **Create** — Insert a new record
|
|
8
|
-
- **Update** — Modify an existing record (Id-based)
|
|
9
|
-
- **Delete** — Remove an existing record (Id-based)
|
|
10
|
-
|
|
11
|
-
Mutations are GA in API v66+. They live under `mutation { uiapi { ... } }` and only support UI API-available objects.
|
|
12
|
-
|
|
13
|
-
## Generation Rules
|
|
14
|
-
|
|
15
|
-
1. **Input fields validation** — Validate that input fields satisfy the constraints for the operation type
|
|
16
|
-
2. **Output fields validation** — Validate that output fields satisfy the constraints for the operation type
|
|
17
|
-
3. **Type consistency** — Variables used as query arguments and their related fields must share the same GraphQL type. Verify types via the schema search script — do NOT assume types
|
|
18
|
-
4. **Input arguments** — `input` is the default argument name unless otherwise specified
|
|
19
|
-
5. **Output field** — For `Create` and `Update`, the output field is always named `Record` (type: EntityName)
|
|
20
|
-
6. **Field name validation** — Every field name in the generated mutation **MUST** match a field confirmed via the schema search script. Do NOT guess or assume field names exist
|
|
21
|
-
7. **Raw input values** — Numeric values must be raw numbers without commas, currency symbols, or locale formatting (e.g., `80000` not `"80,000"` or `"$80,000"`). Compound fields (like addresses) require constituent fields (e.g., `BillingCity`, `BillingStreet`) — do not attempt to set the compound wrapper itself.
|
|
22
|
-
|
|
23
|
-
## Transactional Semantics: `allOrNone`
|
|
24
|
-
|
|
25
|
-
The `uiapi` mutation input accepts an `allOrNone` argument that controls rollback behavior:
|
|
26
|
-
|
|
27
|
-
- **`allOrNone: true` (default)** — If any operation fails, all operations in the request are rolled back. Use when operations must succeed or fail together.
|
|
28
|
-
- **`allOrNone: false`** — Independent operations can succeed individually. However, dependent operations (those using `@{alias}` references) still roll back together with their dependencies.
|
|
29
|
-
|
|
30
|
-
Always set `allOrNone` explicitly to make transactional intent clear.
|
|
31
|
-
|
|
32
|
-
## Mutation Schema Patterns
|
|
33
|
-
|
|
34
|
-
Replace `EntityName` with the actual entity name (e.g., Account, Case). `Delete` operations use generic `Record` types.
|
|
35
|
-
|
|
36
|
-
```graphql
|
|
37
|
-
input EntityNameCreateRepresentation {
|
|
38
|
-
# Subset of EntityName fields
|
|
39
|
-
}
|
|
40
|
-
input EntityNameCreateInput { EntityName: EntityNameCreateRepresentation! }
|
|
41
|
-
type EntityNameCreatePayload { Record: EntityName! }
|
|
42
|
-
|
|
43
|
-
input EntityNameUpdateRepresentation {
|
|
44
|
-
# Subset of EntityName fields
|
|
45
|
-
}
|
|
46
|
-
input EntityNameUpdateInput { Id: IdOrRef! EntityName: EntityNameUpdateRepresentation! }
|
|
47
|
-
type EntityNameUpdatePayload { Record: EntityName! }
|
|
48
|
-
|
|
49
|
-
input RecordDeleteInput { Id: IdOrRef! }
|
|
50
|
-
type RecordDeletePayload { Id: ID }
|
|
51
|
-
|
|
52
|
-
type UIAPIMutations {
|
|
53
|
-
EntityNameCreate(input: EntityNameCreateInput!): EntityNameCreatePayload
|
|
54
|
-
EntityNameDelete(input: RecordDeleteInput!): RecordDeletePayload
|
|
55
|
-
EntityNameUpdate(input: EntityNameUpdateInput!): EntityNameUpdatePayload
|
|
56
|
-
}
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
## Input Field Constraints
|
|
60
|
-
|
|
61
|
-
### Create
|
|
62
|
-
|
|
63
|
-
- **Must** include all required fields (unless `defaultedOnCreate` is `true` and not explicitly requested)
|
|
64
|
-
- **Must** only include `createable` fields
|
|
65
|
-
- Child relationships cannot be set — exclude them
|
|
66
|
-
- Reference fields (`REFERENCE` type) can only be assigned IDs through their `ApiName` name
|
|
67
|
-
- **No nested child creates** — Creating a record with child relationships in a single create operation is not supported. To create a parent and child together, use separate operations with `IdOrRef` chaining (see [Mutation Chaining](#mutation-chaining)).
|
|
68
|
-
|
|
69
|
-
### Update
|
|
70
|
-
|
|
71
|
-
- **Must** include the `Id` of the entity to update
|
|
72
|
-
- **Must** only include `updateable` fields
|
|
73
|
-
- Child relationships cannot be set — exclude them
|
|
74
|
-
- Reference fields (`REFERENCE` type) can only be assigned IDs through their `ApiName` name
|
|
75
|
-
|
|
76
|
-
### Delete
|
|
77
|
-
|
|
78
|
-
- **Must** include the `Id` of the entity to delete
|
|
79
|
-
|
|
80
|
-
## Output Field Constraints
|
|
81
|
-
|
|
82
|
-
### Create and Update
|
|
83
|
-
|
|
84
|
-
- **Must** exclude all child relationships (child relationships cannot be queried in mutations)
|
|
85
|
-
- **Must** exclude all `REFERENCE` fields unless accessed through their `ApiName` member (no navigation to referenced entity, no sub fields)
|
|
86
|
-
- Inaccessible fields are reported in the `errors` attribute of the returned payload
|
|
87
|
-
|
|
88
|
-
### Delete
|
|
89
|
-
|
|
90
|
-
- **Must** only include the `Id` field
|
|
91
|
-
|
|
92
|
-
## Mutation Chaining
|
|
93
|
-
|
|
94
|
-
Chain related mutations in a single request using references to `Id` values from previous mutations. This is the required approach for creating parent-child records together, since nested child creates are not supported.
|
|
95
|
-
|
|
96
|
-
1. **Ordering** — Mutation `B` can reference mutation `A` only if `A` comes first in the query
|
|
97
|
-
2. **Notation** — Use `SomeId: "@{A}"` in mutation `B` to set a field to the `Id` produced by mutation `A`
|
|
98
|
-
3. **IDs only** — `@{A}` is always interpreted as the `Id` from mutation `A`
|
|
99
|
-
4. **Restrictions** — `A` must be a `Create` or `Delete` mutation (chaining from `Update` will fail)
|
|
100
|
-
|
|
101
|
-
### Chaining Example
|
|
102
|
-
|
|
103
|
-
```graphql
|
|
104
|
-
mutation CreateAccountAndContact {
|
|
105
|
-
uiapi(input: { allOrNone: true }) {
|
|
106
|
-
AccountCreate(input: { Account: { Name: "Acme" } }) {
|
|
107
|
-
Record { Id }
|
|
108
|
-
}
|
|
109
|
-
ContactCreate(input: { Contact: { LastName: "Smith", AccountId: "@{AccountCreate}" } }) {
|
|
110
|
-
Record { Id }
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
## Mutation Query Template
|
|
117
|
-
|
|
118
|
-
```graphql
|
|
119
|
-
mutation mutateEntityName(
|
|
120
|
-
# arguments
|
|
121
|
-
) {
|
|
122
|
-
uiapi(input: { allOrNone: true }) {
|
|
123
|
-
EntityNameOperation(input: {
|
|
124
|
-
# For Create and Update only:
|
|
125
|
-
EntityName: {
|
|
126
|
-
# Input fields — use raw values, no formatting
|
|
127
|
-
}
|
|
128
|
-
# For Update and Delete only:
|
|
129
|
-
Id: ... # id here
|
|
130
|
-
}) {
|
|
131
|
-
# For Create and Update only:
|
|
132
|
-
Record {
|
|
133
|
-
# Output fields
|
|
134
|
-
}
|
|
135
|
-
# For Delete only:
|
|
136
|
-
Id
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
```
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
# Query Testing
|
|
2
|
-
|
|
3
|
-
## Testing Method
|
|
4
|
-
|
|
5
|
-
Use `sf api request rest` to POST the query to the GraphQL endpoint. Run from the **SFDX project root** (where `sfdx-project.json` lives).
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
sf api request rest /services/data/v66.0/graphql \
|
|
9
|
-
--method POST \
|
|
10
|
-
--body '{"query":"query GetData { uiapi { query { EntityName { edges { node { Id } } } } } }"}'
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
- Use the API version of the target org (v66.0+ for mutation support, v65.0+ for `@optional`)
|
|
14
|
-
- Replace the `query` value with the generated query string
|
|
15
|
-
- If the query uses variables, include them in the JSON body as a `variables` key
|
|
16
|
-
|
|
17
|
-
## Critical: HTTP 200 Does Not Mean Success
|
|
18
|
-
|
|
19
|
-
Salesforce returns HTTP 200 even when the GraphQL operation has errors (e.g., invalid fields, permission failures, invalid IDs). **Always parse the `errors` array in the response body regardless of HTTP status code.** Do not treat HTTP 200 as confirmation that the query succeeded.
|
|
20
|
-
|
|
21
|
-
## Testing Workflow
|
|
22
|
-
|
|
23
|
-
This workflow applies to both read and mutation queries:
|
|
24
|
-
|
|
25
|
-
1. **Report method** — State the exact method: `sf api request rest` POST to `/services/data/vXX.0/graphql` from the project root
|
|
26
|
-
2. **Ask user** — Ask the user whether they want to test the query. For mutations, also ask for input argument values — mutations modify real data, so explicit consent is essential. Wait for the user's answer before proceeding. Do not fabricate test data.
|
|
27
|
-
3. **Execute test** — Only if the user explicitly agrees. Run `sf api request rest` with the query, variables, and correct API version
|
|
28
|
-
4. **Report result** — Classify the result using the status definitions below. Always check the `errors` array in the response, even on HTTP 200.
|
|
29
|
-
|
|
30
|
-
## Result Status Definitions
|
|
31
|
-
|
|
32
|
-
| Status | Condition | Meaning |
|
|
33
|
-
| --------- | ----------------------------------------------- | --------------------------------------------- |
|
|
34
|
-
| `SUCCESS` | `errors` is absent or empty | Query is valid (even if no data is returned) |
|
|
35
|
-
| `FAILED` | `data` is empty or null | Query is invalid |
|
|
36
|
-
| `PARTIAL` | `data` is present **and** `errors` is not empty | Some fields are inaccessible (mutations only) |
|
|
37
|
-
|
|
38
|
-
## FAILED Status Handling
|
|
39
|
-
|
|
40
|
-
The query is invalid. Follow this sequence:
|
|
41
|
-
|
|
42
|
-
### 1. Error Analysis
|
|
43
|
-
|
|
44
|
-
Parse the `errors` array and check `errors[].extensions.ErrorType` for Salesforce-specific error classification. Categorize into:
|
|
45
|
-
|
|
46
|
-
| Category | ErrorType / Message Contains | Resolution |
|
|
47
|
-
| --------------- | ---------------------------------------------------------------- | ---------------------------------------------------------------------------------- |
|
|
48
|
-
| **Syntax** | `InvalidSyntax` | Fix syntax errors using the error message details |
|
|
49
|
-
| **Validation** | `ValidationError` | Field name is likely invalid — re-run the schema search script, ask user if still unclear |
|
|
50
|
-
| **Type** | `VariableTypeMismatch` or `UnknownType` | Use error details and schema to correct the argument type; adjust variables |
|
|
51
|
-
| **Execution** | `DataFetchingException`, `invalid cross reference id` | Entity is unknown/deleted — create entity first if possible, or ask for a valid Id |
|
|
52
|
-
| **Navigation** | `is not currently available in mutation results` | Field cannot be in mutation output — apply PARTIAL status handling |
|
|
53
|
-
| **Unsupported** | `OperationNotSupported` | The operation is not supported — check object availability and API version |
|
|
54
|
-
| **API Version** | `Cannot invoke JsonElement.isJsonObject()` (on update mutations) | `Record` selection requires API version 64+ — report and retry with version 64 |
|
|
55
|
-
|
|
56
|
-
### 2. Targeted Resolution
|
|
57
|
-
|
|
58
|
-
Apply the resolution from the table above based on the error category. Update the query accordingly.
|
|
59
|
-
|
|
60
|
-
### 3. Test Again
|
|
61
|
-
|
|
62
|
-
Re-run the testing workflow with the updated query. Increment and track the attempt counter.
|
|
63
|
-
|
|
64
|
-
## PARTIAL Status Handling
|
|
65
|
-
|
|
66
|
-
The query executed but some fields are inaccessible (mutations only):
|
|
67
|
-
|
|
68
|
-
1. Report the fields listed in the `errors` attribute
|
|
69
|
-
2. Explain that these fields cannot be queried as part of a mutation
|
|
70
|
-
3. Explain that the query will report errors if these fields remain
|
|
71
|
-
4. Offer to remove the offending fields
|
|
72
|
-
5. **STOP and WAIT** for the user's answer. Do NOT remove fields without explicit consent.
|
|
73
|
-
6. If the user agrees, restart the mutation generation workflow with the updated field list
|
|
74
|
-
|
|
75
|
-
## Retry and Escalation
|
|
76
|
-
|
|
77
|
-
- **Maximum 2 test attempts** per generated query
|
|
78
|
-
- If targeted resolution fails after 2 attempts, ask the user for additional details and **restart the entire workflow from Step 1 (Acquire Schema)** to re-validate entity and field information
|
|
@@ -1,307 +0,0 @@
|
|
|
1
|
-
# Read Query Generation
|
|
2
|
-
|
|
3
|
-
## Generation Rules
|
|
4
|
-
|
|
5
|
-
1. **No proliferation** — Only generate for explicitly requested fields, nothing else. Do NOT add fields the user did not ask for.
|
|
6
|
-
2. **Unique query** — Leverage child relationships to query entities in one single query
|
|
7
|
-
3. **Navigate entities** — Always use `relationshipName` to access reference fields and child entities. Exception: if `relationshipName` is null, return the `Id` itself
|
|
8
|
-
4. **Leverage fragments** — Generate one fragment per possible type on polymorphic fields (fields with `dataType="REFERENCE"` and more than one entry in `referenceToInfos`)
|
|
9
|
-
5. **Type consistency** — Variables used as query arguments and their related fields must share the same GraphQL type. Verify types against the schema search script output — do not assume types
|
|
10
|
-
6. **Type enforcement** — Use field type information from introspection and the GraphQL schema to generate correct field access
|
|
11
|
-
7. **Field name validation** — Every field name in the generated query **MUST** match a field confirmed via the schema search script. Do NOT guess or assume field names exist
|
|
12
|
-
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
|
|
13
|
-
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
|
|
14
|
-
10. **Semi and anti joins** — Use the semi-join or anti-join templates to filter an entity with conditions on child entities
|
|
15
|
-
11. **Explicit pagination** — Always include `first:` in every query to control page size (see [Pagination](#pagination)). Default is 10 if omitted.
|
|
16
|
-
12. **Respect execution limits** — Stay within SOQL-derived limits: max 10 subqueries per request, max 5 child-to-parent relationship levels, max 1 parent-to-child level (no grandchildren), max 55 child-to-parent relationships, max 20 parent-to-child relationships per query
|
|
17
|
-
13. **Compound fields** — When filtering, ordering, or aggregating, use constituent fields (e.g., `BillingCity`, `BillingCountry`) not the compound wrapper (`BillingAddress`). The compound wrapper is only for selection.
|
|
18
|
-
14. **`_Record` suffix awareness** — Objects added to UI API in v60+ may use a `_Record` suffix for their type name (e.g., `FeedItem_Record` instead of `FeedItem`). Always verify type names via schema lookup — do not assume type name equals sObject API name.
|
|
19
|
-
15. **Query generation** — Use the read query template below
|
|
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. Available in API v65.0+.
|
|
24
|
-
|
|
25
|
-
Apply `@optional` to:
|
|
26
|
-
- Scalar fields and value-type fields (e.g. `Name { value }`)
|
|
27
|
-
- Parent relationships
|
|
28
|
-
- Child relationships
|
|
29
|
-
|
|
30
|
-
**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.
|
|
31
|
-
|
|
32
|
-
```ts
|
|
33
|
-
// Defend against missing fields
|
|
34
|
-
const name = node.Name?.value ?? '';
|
|
35
|
-
const relatedName = node.RelationshipName?.Name?.value ?? 'N/A';
|
|
36
|
-
|
|
37
|
-
// Unsafe — will throw if field omitted due to FLS
|
|
38
|
-
const name = node.Name.value;
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
## Pagination
|
|
42
|
-
|
|
43
|
-
Salesforce GraphQL uses Relay Cursor Connections with **forward-only pagination**. There is no backward pagination (`last`/`before` are not supported).
|
|
44
|
-
|
|
45
|
-
### Core Rules
|
|
46
|
-
|
|
47
|
-
- **Always specify `first:`** — If omitted, the server defaults to 10 records. Be explicit.
|
|
48
|
-
- **Forward-only** — Use `first` and `after` only. Do **not** use `last` or `before` — they are unsupported and will fail.
|
|
49
|
-
- **Maximum without upperBound** — Standard pagination allows up to 4,000 total records across pages.
|
|
50
|
-
- **Use `pageInfo`** — Select `pageInfo { hasNextPage endCursor }` for any query that may need pagination.
|
|
51
|
-
|
|
52
|
-
### UpperBound Pagination (v59+)
|
|
53
|
-
|
|
54
|
-
When you need more than 200 records per page or more than 4,000 total records, switch to upperBound mode:
|
|
55
|
-
|
|
56
|
-
- **`first` must be 200–2000** when `upperBound` is set. Values below 200 are invalid.
|
|
57
|
-
- **`upperBound`** declares the estimated total record count and enables extended pagination.
|
|
58
|
-
|
|
59
|
-
```graphql
|
|
60
|
-
# Standard pagination
|
|
61
|
-
Account(first: 50, after: $cursor) {
|
|
62
|
-
edges { node { Id Name @optional { value } } }
|
|
63
|
-
pageInfo { hasNextPage endCursor }
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
# UpperBound pagination for large result sets
|
|
67
|
-
Account(first: 2000, after: $cursor, upperBound: 10000) {
|
|
68
|
-
edges { node { Id Name @optional { value } } }
|
|
69
|
-
pageInfo { hasNextPage endCursor }
|
|
70
|
-
}
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
## Ordering
|
|
74
|
-
|
|
75
|
-
Use the `orderBy:` argument with generated `<Object>_OrderBy` input types. Run the schema search script to verify sortable fields.
|
|
76
|
-
|
|
77
|
-
### Rules
|
|
78
|
-
|
|
79
|
-
- Use `orderBy:` with the generated OrderBy type: `orderBy: { FieldName: { order: ASC } }`
|
|
80
|
-
- **Multi-column sorting** is supported by combining fields in the orderBy input
|
|
81
|
-
- **Unsupported field types** for ordering: multi-select picklist, rich text, long text area, encrypted fields. Do not order by these.
|
|
82
|
-
- **Locale sensitivity** — Sort order depends on user locale. For deterministic ordering, add `Id` as a tie-breaker field.
|
|
83
|
-
- **Compound fields** — Use constituent fields for ordering (e.g., `BillingCity`), not the compound wrapper.
|
|
84
|
-
|
|
85
|
-
```graphql
|
|
86
|
-
Account(
|
|
87
|
-
first: 10,
|
|
88
|
-
orderBy: { Name: { order: ASC }, CreatedDate: { order: DESC } }
|
|
89
|
-
) { ... }
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
## Filtering
|
|
93
|
-
|
|
94
|
-
### Boolean Filter Composition
|
|
95
|
-
|
|
96
|
-
Filter types include `AND`, `OR`, and `NOT` fields for combining conditions. Multiple filter fields at the same level combine with implicit AND.
|
|
97
|
-
|
|
98
|
-
```graphql
|
|
99
|
-
# Implicit AND — both conditions must match
|
|
100
|
-
Account(where: { Industry: { eq: "Technology" }, AnnualRevenue: { gt: 1000000 } })
|
|
101
|
-
|
|
102
|
-
# Explicit OR
|
|
103
|
-
Account(where: { OR: [
|
|
104
|
-
{ Industry: { eq: "Technology" } },
|
|
105
|
-
{ Industry: { eq: "Finance" } }
|
|
106
|
-
] })
|
|
107
|
-
|
|
108
|
-
# NOT
|
|
109
|
-
Account(where: { NOT: { Industry: { eq: "Technology" } } })
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
### Date and DateTime Filtering
|
|
113
|
-
|
|
114
|
-
Date and DateTime fields use special input objects (`DateInput`/`DateTimeInput`) that support both literal values and SOQL-style relative date semantics.
|
|
115
|
-
|
|
116
|
-
```graphql
|
|
117
|
-
# Literal date
|
|
118
|
-
Opportunity(where: { CloseDate: { eq: { value: "2024-12-31" } } })
|
|
119
|
-
|
|
120
|
-
# Relative date literal
|
|
121
|
-
Opportunity(where: { CloseDate: { gte: { literal: TODAY } } })
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
Verify exact literal enum values (e.g., `TODAY`, `THIS_MONTH`) via the schema search script.
|
|
125
|
-
|
|
126
|
-
### String Equality Is Case-Insensitive
|
|
127
|
-
|
|
128
|
-
String comparisons with `eq` are case-insensitive in Salesforce GraphQL. Do not rely on case sensitivity for string equality filters.
|
|
129
|
-
|
|
130
|
-
### Relationship Filters
|
|
131
|
-
|
|
132
|
-
Filter through parent relationships using nested filter objects (not dot notation):
|
|
133
|
-
|
|
134
|
-
```graphql
|
|
135
|
-
# Correct — nested filter objects
|
|
136
|
-
Contact(where: { Account: { Name: { like: "Acme%" } } })
|
|
137
|
-
|
|
138
|
-
# Wrong — dot notation is not supported
|
|
139
|
-
Contact(where: { "Account.Name": { like: "Acme%" } })
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
### Polymorphic Relationship Filters
|
|
143
|
-
|
|
144
|
-
Polymorphic relationships use union-aware filter input types named `<Object>_<RelationshipName>_Filters`. Filter by specific concrete types within the union:
|
|
145
|
-
|
|
146
|
-
```graphql
|
|
147
|
-
# Filter by polymorphic Owner (which is a union of User, Group, etc.)
|
|
148
|
-
Account(where: { Owner: { User: { Username: { like: "admin%" } } } })
|
|
149
|
-
```
|
|
150
|
-
|
|
151
|
-
Verify exact filter input type names and available concrete types via the schema search script.
|
|
152
|
-
|
|
153
|
-
### ID Filtering
|
|
154
|
-
|
|
155
|
-
Salesforce accepts both 15-character and 18-character record IDs for `Id` filtering. Do not reject or "correct" either form.
|
|
156
|
-
|
|
157
|
-
## Semi-Join and Anti-Join Templates
|
|
158
|
-
|
|
159
|
-
Semi-joins and anti-joins filter a parent entity using conditions on child entities. They use `inq` (semi-join) and `ninq` (anti-join) operators on the parent entity's `Id`.
|
|
160
|
-
|
|
161
|
-
The operator accepts:
|
|
162
|
-
|
|
163
|
-
- The child entity camelCase name with conditions
|
|
164
|
-
- The `ApiName` field containing the parent entity `Id` (`fieldName` from `childRelationships`)
|
|
165
|
-
|
|
166
|
-
If the only condition is child entity existence, use `Id: { ne: null }`.
|
|
167
|
-
|
|
168
|
-
### Restrictions
|
|
169
|
-
|
|
170
|
-
Semi-join and anti-join queries have SOQL-derived restrictions:
|
|
171
|
-
- **Limited count** — There are limits on the number of `inq`/`ninq` operators per query
|
|
172
|
-
- **No `ne` with joins** — Cannot use `ne` operator in combination with join operators
|
|
173
|
-
- **No `or` in subquery** — The join subquery conditions cannot use `OR`
|
|
174
|
-
- **No `orderBy` in subquery** — Join subqueries do not support ordering
|
|
175
|
-
- **Nesting restrictions** — Semi/anti-joins cannot be nested within each other
|
|
176
|
-
|
|
177
|
-
### Semi-Join Example
|
|
178
|
-
|
|
179
|
-
Filter `ParentEntity` to include only those with at least one matching `ChildEntity`:
|
|
180
|
-
|
|
181
|
-
```graphql
|
|
182
|
-
query testSemiJoin {
|
|
183
|
-
uiapi {
|
|
184
|
-
query {
|
|
185
|
-
ParentEntity(
|
|
186
|
-
where: {
|
|
187
|
-
Id: {
|
|
188
|
-
inq: {
|
|
189
|
-
ChildEntity: {
|
|
190
|
-
Name: { like: "test%" }
|
|
191
|
-
Type: { eq: "some value" }
|
|
192
|
-
}
|
|
193
|
-
ApiName: "parentIdFieldInChild"
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
) {
|
|
198
|
-
edges {
|
|
199
|
-
node {
|
|
200
|
-
Id
|
|
201
|
-
Name @optional {
|
|
202
|
-
value
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
```
|
|
211
|
-
|
|
212
|
-
### Anti-Join Example
|
|
213
|
-
|
|
214
|
-
Same as the semi-join example, but replace `inq` with `ninq` to filter `ParentEntity` with **no** matching `ChildEntity`.
|
|
215
|
-
|
|
216
|
-
## Current User Exception
|
|
217
|
-
|
|
218
|
-
To retrieve **current user**, **connected user**, or **authenticated user** information, use `uiapi.currentUser` instead of the standard query pattern. This field takes **no arguments** and returns a `User` type.
|
|
219
|
-
|
|
220
|
-
## Conditional Field Selection
|
|
221
|
-
|
|
222
|
-
For dynamic fieldsets with **known** fields, use `@include(if: $condition)` and `@skip(if: $condition)` directives in `.graphql` files. See GraphQL spec for details.
|
|
223
|
-
|
|
224
|
-
## Read Query Template
|
|
225
|
-
|
|
226
|
-
```graphql
|
|
227
|
-
query QueryName($after: String) {
|
|
228
|
-
uiapi {
|
|
229
|
-
query {
|
|
230
|
-
EntityName(
|
|
231
|
-
first: 10 # Always specify — default is 10 if omitted
|
|
232
|
-
after: $after # For pagination
|
|
233
|
-
where: { ... } # Filter conditions
|
|
234
|
-
orderBy: { ... } # Sort order
|
|
235
|
-
) {
|
|
236
|
-
edges {
|
|
237
|
-
node {
|
|
238
|
-
# Direct fields — use @optional for FLS resilience
|
|
239
|
-
FieldName @optional { value }
|
|
240
|
-
|
|
241
|
-
# Non-polymorphic reference (single type)
|
|
242
|
-
RelationshipName @optional {
|
|
243
|
-
Id
|
|
244
|
-
Name { value }
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
# Polymorphic reference (multiple types)
|
|
248
|
-
PolymorphicRelationshipName @optional {
|
|
249
|
-
...TypeAInfo
|
|
250
|
-
...TypeBInfo
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
# Child relationship (subquery) — max 1 level deep, no grandchildren
|
|
254
|
-
RelationshipName @optional (
|
|
255
|
-
first: 10 # Always specify
|
|
256
|
-
) {
|
|
257
|
-
edges {
|
|
258
|
-
node {
|
|
259
|
-
# fields
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
pageInfo {
|
|
266
|
-
hasNextPage
|
|
267
|
-
endCursor
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
fragment TypeAInfo on TypeA {
|
|
275
|
-
Id
|
|
276
|
-
SpecificFieldA @optional { value }
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
fragment TypeBInfo on TypeB {
|
|
280
|
-
Id
|
|
281
|
-
SpecificFieldB @optional { value }
|
|
282
|
-
}
|
|
283
|
-
```
|
|
284
|
-
|
|
285
|
-
## Field Value Wrappers
|
|
286
|
-
|
|
287
|
-
Schema fields use typed wrappers. Access the underlying value via `.value`:
|
|
288
|
-
|
|
289
|
-
| Wrapper Type | Underlying Type | Access Pattern |
|
|
290
|
-
| ----------------- | --------------- | --------------------- |
|
|
291
|
-
| `StringValue` | `String` | `field { value }` |
|
|
292
|
-
| `IntValue` | `Int` | `field { value }` |
|
|
293
|
-
| `CurrencyValue` | `Currency` | `field { value }` |
|
|
294
|
-
| `DateTimeValue` | `DateTime` | `field { value }` |
|
|
295
|
-
| `PicklistValue` | `Picklist` | `field { value }` |
|
|
296
|
-
| `BooleanValue` | `Boolean` | `field { value }` |
|
|
297
|
-
| `DoubleValue` | `Double` | `field { value }` |
|
|
298
|
-
| `PercentValue` | `Percent` | `field { value }` |
|
|
299
|
-
| `IDValue` | `ID` | `field { value }` |
|
|
300
|
-
| `EmailValue` | `Email` | `field { value }` |
|
|
301
|
-
| `PhoneNumberValue`| `PhoneNumber` | `field { value }` |
|
|
302
|
-
| `UrlValue` | `Url` | `field { value }` |
|
|
303
|
-
| `DateValue` | `Date` | `field { value }` |
|
|
304
|
-
| `LongValue` | `Long` | `field { value }` |
|
|
305
|
-
| `TextAreaValue` | `TextArea` | `field { value }` |
|
|
306
|
-
|
|
307
|
-
All wrappers also expose `displayValue: String` for formatted display. `displayValue` is server-rendered using SOQL `toLabel()` or `format()` depending on field type — use it for UI display instead of formatting values client-side.
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
# Schema Introspection
|
|
2
|
-
|
|
3
|
-
## Schema Access Policy
|
|
4
|
-
|
|
5
|
-
The `schema.graphql` file is **265,000+ lines**. Loading it into context or opening it in an editor will overwhelm the context window or crash tools.
|
|
6
|
-
|
|
7
|
-
Do not use cat, less, more, head, tail, editors (VS Code, vim, nano), or programmatic parsers (node, python, awk, sed, jq) on `schema.graphql`. Use the schema search script or targeted grep calls only.
|
|
8
|
-
|
|
9
|
-
## Schema Lookup
|
|
10
|
-
|
|
11
|
-
Run the search script from the **SFDX project root** to get all relevant schema info in one step:
|
|
12
|
-
|
|
13
|
-
```bash
|
|
14
|
-
bash scripts/graphql-search.sh <EntityName>
|
|
15
|
-
# Multiple entities:
|
|
16
|
-
bash scripts/graphql-search.sh Account Contact Opportunity
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
**Maximum 2 script runs.** If the entity still can't be found after checking naming variations, ask the user.
|
|
20
|
-
|
|
21
|
-
## Entity Identification
|
|
22
|
-
|
|
23
|
-
Map user intent to PascalCase entity names:
|
|
24
|
-
|
|
25
|
-
1. Convert natural language to PascalCase (e.g., "accounts" → `Account`, "case comments" → `CaseComment`, "custom objects" → `CustomObject__c`)
|
|
26
|
-
2. Run the schema search script to validate the entity exists
|
|
27
|
-
3. If a candidate does not match, try:
|
|
28
|
-
- `__c` suffix for custom objects, `__e` for platform events
|
|
29
|
-
- **`_Record` suffix** — Objects added to UI API in API v60+ may use `<EntityName>_Record` as their type name (e.g., `FeedItem_Record` instead of `FeedItem`)
|
|
30
|
-
4. If an entity cannot be resolved, **ask the user** for the correct name — do not guess
|
|
31
|
-
|
|
32
|
-
## Iterative Introspection
|
|
33
|
-
|
|
34
|
-
Use a maximum of **3 introspection cycles** to resolve all entities and their dependencies:
|
|
35
|
-
|
|
36
|
-
1. **Introspect** — Run the schema search script for each unresolved entity
|
|
37
|
-
2. **Fields** — Extract requested field names and types from the type definition output
|
|
38
|
-
3. **References** — Identify reference fields. If a reference resolves to multiple types, mark it as **polymorphic** (use inline fragments in the generated query). Add newly discovered entity types to the working list.
|
|
39
|
-
4. **Child relationships** — Identify Connection types (e.g., `Contacts: ContactConnection`). Add child entity types to the working list.
|
|
40
|
-
5. **Next cycle** — If unresolved entities remain and the cycle limit hasn't been reached, repeat from step 1
|
|
41
|
-
|
|
42
|
-
### Hard Stop Rules
|
|
43
|
-
|
|
44
|
-
- If no introspection data is returned for an entity, **stop** — the entity may not be deployed
|
|
45
|
-
- If unknown entities remain after 3 cycles, **stop** — ask the user for clarification
|
|
46
|
-
- Do not proceed with query generation until all entities and requested fields are confirmed in the schema
|
|
47
|
-
|
|
48
|
-
## Deployment Prerequisites
|
|
49
|
-
|
|
50
|
-
The schema reflects the **current org state**. Custom objects and fields appear only after metadata is deployed.
|
|
51
|
-
|
|
52
|
-
- **Before** running `npm run graphql:schema`: Deploy all metadata and assign permission sets. Invoke the `deploying-ui-bundle` skill for the full sequence.
|
|
53
|
-
- **After** any metadata deployment: Re-run `npm run graphql:schema` and `npm run graphql:codegen` so types and queries stay in sync.
|