From 0d2e225a66110e5b9f40e541fb98fede7c8602eb Mon Sep 17 00:00:00 2001 From: Avram Walden Date: Wed, 2 Oct 2024 17:47:48 -0700 Subject: [PATCH] feat: starts trying to use queryOptions --- app/frontend/queries/commands/index.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/app/frontend/queries/commands/index.ts b/app/frontend/queries/commands/index.ts index e59a281..e30d74c 100644 --- a/app/frontend/queries/commands/index.ts +++ b/app/frontend/queries/commands/index.ts @@ -1,16 +1,19 @@ -import { useQuery } from '@tanstack/react-query' +import { useQuery, queryOptions } from '@tanstack/react-query' import { Routes } from '@/lib' import axios from 'axios' import { ComboboxData } from '@mantine/core' import { type ReactQueryFunction } from '..' +import queryKeys from '../queryKeys' export const useGetCommand: ReactQueryFunction = ({ slug }, options) => { return useQuery({ - queryKey: [`command/${slug}`], - queryFn: async () => { - const res = await axios.get(Routes.apiCommand(slug)) - return res.data - }, + ...queryOptions({ + queryKey: queryKeys.commands.detail(slug), + queryFn: async () => { + const res = await axios.get(Routes.apiCommand(slug)) + return res.data + }, + }), ...options, }) }