Request body is now an object

This commit is contained in:
Gregory Schier
2023-11-12 11:16:12 -08:00
parent ef23a85577
commit 758154fa14
16 changed files with 73 additions and 54 deletions

View File

@@ -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]);
}

View File

@@ -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 {

View File

@@ -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 }) {

View File

@@ -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) {

View File

@@ -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() {

View File

@@ -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 ?? []
);