Skip to content

Commit bf1cb68

Browse files
committed
fix: also include sourceMap and encodeDataAttribute in non-awaited result
1 parent bfe8745 commit bf1cb68

1 file changed

Lines changed: 14 additions & 10 deletions

File tree

src/runtime/composables/visual-editing.ts

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -246,15 +246,15 @@ export const useSanityQuery = <T = unknown, E = Error> (
246246
}
247247

248248
const proxyClient = {
249-
fetch: <T>(
250-
query: string,
251-
params: QueryParams,
252-
options: UnfilteredResponseQueryOptions,
253-
): Promise<{ result: T, resultSourceMap: ContentSourceMap }> =>
254-
$fetch(sanity.config.visualEditing!.proxyEndpoint, {
255-
method: 'POST',
256-
body: { query, params, options },
257-
}),
249+
fetch: <T> (
250+
query: string,
251+
params: QueryParams,
252+
options: UnfilteredResponseQueryOptions,
253+
): Promise<{ result: T, resultSourceMap: ContentSourceMap }> =>
254+
$fetch(sanity.config.visualEditing!.proxyEndpoint, {
255+
method: 'POST',
256+
body: { query, params, options },
257+
}),
258258
}
259259

260260
result = useAsyncData<SanityQueryResponse<T | null>, E>(
@@ -287,7 +287,11 @@ export const useSanityQuery = <T = unknown, E = Error> (
287287
onScopeDispose(unsubscribe)
288288
}
289289

290-
return Object.assign(result, new Promise(resolve => {
290+
return Object.assign(result, {
291+
data,
292+
sourceMap,
293+
encodeDataAttribute,
294+
}, new Promise(resolve => {
291295
result.then(value => {
292296
updateRefs(value.data.value.data, value.data.value.sourceMap)
293297
resolve({

0 commit comments

Comments
 (0)