I have a graphql query that returns a zip file rather than a results.. I am not sure how to capture this to pop up so it can be downloaded. I have googled this subject to death and not really finding anything.
function exportAwardsUseQuery() {
const apolloExportClient = new ApolloClient({
uri: import.meta.env.VITE_EXPORT_URL,
cache: new InMemoryCache(),
});
provideApolloClient(apolloExportClient);
const { result, error, loading, onResult } = useQuery(EXPORT_AWARDS, filterStore.getFilterList);
onResult((result) => {
const blob = new Blob([result as unknown as Blob], { type: "application/zip" });
const link = document.createElement("a");
link.href = window.URL.createObjectURL(blob);
link.download = "export.zip";
link.click();
});
}
onResult never executes..
I can see the blob in the dev tools network tab. It does not return a result ref, just returns the zip file as a blob.