mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-20 16:43:53 +01:00
Better schema fetching
This commit is contained in:
@@ -60,12 +60,13 @@ export function GraphQLEditor({ defaultValue, onChange, baseRequest, ...extraEdi
|
||||
const editorViewRef = useRef<EditorView>(null);
|
||||
|
||||
useEffect(() => {
|
||||
let unmounted = false;
|
||||
const body = JSON.stringify({
|
||||
query: getIntrospectionQuery(),
|
||||
operationName: 'IntrospectionQuery',
|
||||
});
|
||||
const req: HttpRequest = { ...baseRequest, body, id: '' };
|
||||
sendEphemeralRequest(req).then((response) => {
|
||||
sendEphemeralRequest({ ...baseRequest, body }).then((response) => {
|
||||
if (unmounted) return;
|
||||
try {
|
||||
if (editorViewRef.current) {
|
||||
const { data } = JSON.parse(response.body);
|
||||
@@ -77,6 +78,9 @@ export function GraphQLEditor({ defaultValue, onChange, baseRequest, ...extraEdi
|
||||
return;
|
||||
}
|
||||
});
|
||||
return () => {
|
||||
unmounted = true;
|
||||
};
|
||||
}, [baseRequest.url]);
|
||||
|
||||
return (
|
||||
|
||||
@@ -2,5 +2,7 @@ import { invoke } from '@tauri-apps/api';
|
||||
import type { HttpRequest, HttpResponse } from './models';
|
||||
|
||||
export function sendEphemeralRequest(request: HttpRequest): Promise<HttpResponse> {
|
||||
return invoke('send_ephemeral_request', { request });
|
||||
// Ensure it's not associated with an ID
|
||||
const newRequest = { ...request, id: '' };
|
||||
return invoke('send_ephemeral_request', { request: newRequest });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user