Commit d5706ee
authored
fix(next): conditionally query snapshot field based on localization (#15693)
# Overview
Fixes a query validation error in the Versions view that occurs when
viewing versions for collections without localization enabled.
## Key Changes
- Made the `snapshot` query conditional on localization in
`fetchLatestVersion` calls
- The `snapshot` field only exists in version schemas when
`config.localization` is enabled
- Collections without localization (e.g., trash tests) would fail with
"The following path cannot be queried: snapshot"
- Aligns with the existing pattern already used earlier in the same file
## Design Decisions
The fix follows the existing pattern in the same file where the
`snapshot` filter is conditionally applied:
```typescript
if (localization && draftsEnabled) {
whereQuery.and.push({ snapshot: { not_equals: true } })
}
```
The two `fetchLatestVersion` calls for `currentlyPublishedVersion` and
`latestDraftVersion` were missing this guard, causing failures when
localization is disabled.
When localization is disabled, no snapshot versions exist anyway, so the
filter is unnecessary.1 parent 139cf3e commit d5706ee
1 file changed
Lines changed: 14 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
109 | 111 | | |
110 | 112 | | |
111 | 113 | | |
| |||
127 | 129 | | |
128 | 130 | | |
129 | 131 | | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
135 | 139 | | |
136 | 140 | | |
137 | 141 | | |
| |||
0 commit comments