Skip to content

Commit

Permalink
Fix sending of ephemeral requests
Browse files Browse the repository at this point in the history
  • Loading branch information
gschier committed Oct 30, 2023
1 parent 0fc8d12 commit 32b135d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src-web/hooks/useIntrospectGraphQL.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import type { HttpRequest } from '../lib/models';
import { getResponseBodyText } from '../lib/responseBody';
import { sendEphemeralRequest } from '../lib/sendEphemeralRequest';
import { useDebouncedValue } from './useDebouncedValue';
import { useActiveEnvironmentId } from './useActiveEnvironmentId';

const introspectionRequestBody = JSON.stringify({
query: getIntrospectionQuery(),
Expand All @@ -17,6 +18,7 @@ export function useIntrospectGraphQL(baseRequest: HttpRequest) {
// Debounce the request because it can change rapidly and we don't
// want to send so too many requests.
const request = useDebouncedValue(baseRequest);
const activeEnvironmentId = useActiveEnvironmentId();
const [refetchKey, setRefetchKey] = useState<number>(0);
const [isLoading, setIsLoading] = useState<boolean>(false);
const [error, setError] = useState<string>();
Expand All @@ -31,7 +33,7 @@ export function useIntrospectGraphQL(baseRequest: HttpRequest) {
setIsLoading(true);
setError(undefined);
const args = { ...baseRequest, body: introspectionRequestBody };
const response = await minPromiseMillis(sendEphemeralRequest(args), 700);
const response = await minPromiseMillis(sendEphemeralRequest(args, activeEnvironmentId), 700);

if (response.error) {
return Promise.reject(new Error(response.error));
Expand Down
4 changes: 2 additions & 2 deletions src-web/lib/sendEphemeralRequest.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { invoke } from '@tauri-apps/api';
import type { HttpRequest, HttpResponse } from './models';

export async function sendEphemeralRequest(request: HttpRequest): Promise<HttpResponse> {
export async function sendEphemeralRequest(request: HttpRequest, environmentId: string | null): Promise<HttpResponse> {
// Remove some things that we don't want to associate
const newRequest = { ...request, id: '', requestId: '', workspaceId: '' };
return invoke('send_ephemeral_request', { request: newRequest });
return invoke('send_ephemeral_request', { request: newRequest, environmentId });
}

0 comments on commit 32b135d

Please sign in to comment.