Skip to content

Commit d5706ee

Browse files
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

File tree

packages/next/src/views/Versions/index.tsx

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,13 @@ export async function VersionsView(props: DocumentViewServerProps) {
101101
},
102102
status: 'published',
103103
user,
104-
where: {
105-
snapshot: {
106-
not_equals: true,
107-
},
108-
},
104+
where: localization
105+
? {
106+
snapshot: {
107+
not_equals: true,
108+
},
109+
}
110+
: undefined,
109111
})
110112
: Promise.resolve(null),
111113
draftsEnabled
@@ -127,11 +129,13 @@ export async function VersionsView(props: DocumentViewServerProps) {
127129
},
128130
status: 'draft',
129131
user,
130-
where: {
131-
snapshot: {
132-
not_equals: true,
133-
},
134-
},
132+
where: localization
133+
? {
134+
snapshot: {
135+
not_equals: true,
136+
},
137+
}
138+
: undefined,
135139
})
136140
: Promise.resolve(null),
137141
])

0 commit comments

Comments
 (0)