mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-23 09:51:10 +01:00
Request body is now an object
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { useCallback, useMemo } from 'react';
|
||||
import { useMemo } from 'react';
|
||||
import type { Environment } from '../lib/models';
|
||||
import { useActiveEnvironmentId } from './useActiveEnvironmentId';
|
||||
import { useEnvironments } from './useEnvironments';
|
||||
@@ -6,10 +6,5 @@ import { useEnvironments } from './useEnvironments';
|
||||
export function useActiveEnvironment(): Environment | null {
|
||||
const id = useActiveEnvironmentId();
|
||||
const environments = useEnvironments();
|
||||
const environment = useMemo(
|
||||
() => environments.find((w) => w.id === id) ?? null,
|
||||
[environments, id],
|
||||
);
|
||||
|
||||
return environment;
|
||||
return useMemo(() => environments.find((w) => w.id === id) ?? null, [environments, id]);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { useCallback } from 'react';
|
||||
import { useParams, useSearchParams } from 'react-router-dom';
|
||||
import { useParams } from 'react-router-dom';
|
||||
import type { RouteParamsRequest } from './useAppRoutes';
|
||||
|
||||
export function useActiveEnvironmentId(): string | null {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { invoke } from '@tauri-apps/api';
|
||||
import type { Folder, HttpRequest } from '../lib/models';
|
||||
import type { Folder } from '../lib/models';
|
||||
import { useActiveWorkspaceId } from './useActiveWorkspaceId';
|
||||
|
||||
export function foldersQueryKey({ workspaceId }: { workspaceId: string }) {
|
||||
|
||||
@@ -32,7 +32,11 @@ export function useIntrospectGraphQL(baseRequest: HttpRequest) {
|
||||
const fetchIntrospection = async () => {
|
||||
setIsLoading(true);
|
||||
setError(undefined);
|
||||
const args = { ...baseRequest, body: introspectionRequestBody };
|
||||
const args = {
|
||||
...baseRequest,
|
||||
bodyType: 'graphql',
|
||||
body: { text: introspectionRequestBody },
|
||||
};
|
||||
const response = await minPromiseMillis(sendEphemeralRequest(args, activeEnvironmentId), 700);
|
||||
|
||||
if (response.error) {
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
||||
import { invoke } from '@tauri-apps/api';
|
||||
import type { Folder, HttpRequest } from '../lib/models';
|
||||
import { getFolder, getRequest } from '../lib/store';
|
||||
import { requestsQueryKey } from './useRequests';
|
||||
import type { Folder } from '../lib/models';
|
||||
import { getFolder } from '../lib/store';
|
||||
import { foldersQueryKey } from './useFolders';
|
||||
|
||||
export function useUpdateAnyFolder() {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { invoke } from '@tauri-apps/api';
|
||||
import type { Variable } from '../lib/models';
|
||||
import type { EnvironmentVariable } from '../lib/models';
|
||||
|
||||
export function variablesQueryKey({ environmentId }: { environmentId: string }) {
|
||||
return ['variables', { environmentId }];
|
||||
@@ -11,7 +11,7 @@ export function useVariables({ environmentId }: { environmentId: string }) {
|
||||
useQuery({
|
||||
queryKey: variablesQueryKey({ environmentId }),
|
||||
queryFn: async () => {
|
||||
return (await invoke('list_variables', { environmentId })) as Variable[];
|
||||
return (await invoke('list_variables', { environmentId })) as EnvironmentVariable[];
|
||||
},
|
||||
}).data ?? []
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user