mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-21 16:31:18 +02: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);
|
const editorViewRef = useRef<EditorView>(null);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
let unmounted = false;
|
||||||
const body = JSON.stringify({
|
const body = JSON.stringify({
|
||||||
query: getIntrospectionQuery(),
|
query: getIntrospectionQuery(),
|
||||||
operationName: 'IntrospectionQuery',
|
operationName: 'IntrospectionQuery',
|
||||||
});
|
});
|
||||||
const req: HttpRequest = { ...baseRequest, body, id: '' };
|
sendEphemeralRequest({ ...baseRequest, body }).then((response) => {
|
||||||
sendEphemeralRequest(req).then((response) => {
|
if (unmounted) return;
|
||||||
try {
|
try {
|
||||||
if (editorViewRef.current) {
|
if (editorViewRef.current) {
|
||||||
const { data } = JSON.parse(response.body);
|
const { data } = JSON.parse(response.body);
|
||||||
@@ -77,6 +78,9 @@ export function GraphQLEditor({ defaultValue, onChange, baseRequest, ...extraEdi
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
return () => {
|
||||||
|
unmounted = true;
|
||||||
|
};
|
||||||
}, [baseRequest.url]);
|
}, [baseRequest.url]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -2,5 +2,7 @@ import { invoke } from '@tauri-apps/api';
|
|||||||
import type { HttpRequest, HttpResponse } from './models';
|
import type { HttpRequest, HttpResponse } from './models';
|
||||||
|
|
||||||
export function sendEphemeralRequest(request: HttpRequest): Promise<HttpResponse> {
|
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