Skip to content

Commit

Permalink
fix: also include sourceMap and encodeDataAttribute in non-awaite…
Browse files Browse the repository at this point in the history
…d result
  • Loading branch information
danielroe committed Apr 2, 2024
1 parent bfe8745 commit bf1cb68
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src/runtime/composables/visual-editing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,15 +246,15 @@ export const useSanityQuery = <T = unknown, E = Error> (
}

const proxyClient = {
fetch: <T>(
query: string,
params: QueryParams,
options: UnfilteredResponseQueryOptions,
): Promise<{ result: T, resultSourceMap: ContentSourceMap }> =>
$fetch(sanity.config.visualEditing!.proxyEndpoint, {
method: 'POST',
body: { query, params, options },
}),
fetch: <T> (
query: string,
params: QueryParams,
options: UnfilteredResponseQueryOptions,
): Promise<{ result: T, resultSourceMap: ContentSourceMap }> =>
$fetch(sanity.config.visualEditing!.proxyEndpoint, {
method: 'POST',
body: { query, params, options },
}),
}

result = useAsyncData<SanityQueryResponse<T | null>, E>(
Expand Down Expand Up @@ -287,7 +287,11 @@ export const useSanityQuery = <T = unknown, E = Error> (
onScopeDispose(unsubscribe)
}

return Object.assign(result, new Promise(resolve => {
return Object.assign(result, {
data,
sourceMap,
encodeDataAttribute,
}, new Promise(resolve => {
result.then(value => {
updateRefs(value.data.value.data, value.data.value.sourceMap)
resolve({
Expand Down

0 comments on commit bf1cb68

Please sign in to comment.