mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-24 02:11:10 +01:00
Fix graphql instrospection
This commit is contained in:
@@ -1,22 +1,11 @@
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { readTextFile } from '@tauri-apps/api/fs';
|
||||
import type { HttpResponse } from '../lib/models';
|
||||
import { getResponseBodyText } from '../lib/responseBody';
|
||||
|
||||
export function useResponseBodyText(response: HttpResponse) {
|
||||
return useQuery<string | null>({
|
||||
queryKey: ['response-body-text', response?.updatedAt],
|
||||
initialData: null,
|
||||
queryFn: async () => {
|
||||
if (response.body) {
|
||||
const uint8Array = Uint8Array.of(...response.body);
|
||||
return new TextDecoder().decode(uint8Array);
|
||||
}
|
||||
|
||||
if (response.bodyPath) {
|
||||
return await readTextFile(response.bodyPath);
|
||||
}
|
||||
|
||||
return null;
|
||||
},
|
||||
queryFn: () => getResponseBodyText(response),
|
||||
}).data;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user