refactor: rewrite useApps with RQ

This commit is contained in:
Rıdvan Akca
2024-03-04 17:25:49 +03:00
parent 1870aead73
commit e5670d820d
5 changed files with 76 additions and 21 deletions

View File

@@ -1,12 +1,19 @@
import { useQuery } from '@apollo/client';
import { GET_APPS } from 'graphql/queries/get-apps';
import { useQuery } from '@tanstack/react-query';
import api from 'helpers/api';
export default function useApps(variables) {
const { data, loading } = useQuery(GET_APPS, {
variables,
const query = useQuery({
queryKey: ['apps', variables],
queryFn: async ({ payload, signal }) => {
const { data } = await api.get('/v1/apps', {
params: variables,
signal,
});
return data;
},
});
const apps = data?.getApps;
return {
apps,
loading,
};
return query;
}