diff --git a/src/item/api.ts b/src/item/api.ts index b289c150..0f13c724 100644 --- a/src/item/api.ts +++ b/src/item/api.ts @@ -5,7 +5,6 @@ import { PackedRecycledItemData, ResultOf, UUID, - getParentFromPath, } from '@graasp/sdk'; import { verifyAuthentication } from '../api/axios.js'; @@ -97,16 +96,9 @@ export const getChildren = async ( .then(({ data }) => data); export const getParents = async ( - { id, path }: { id: UUID; path?: string }, + { id }: { id: UUID }, { API_HOST, axios }: PartialQueryConfigForApi, ) => { - // shortcut to prevent fetching parents if path shows that item is a root - if (path) { - const parentId = getParentFromPath(path); - if (!parentId) { - return []; - } - } return axios .get(`${API_HOST}/${buildGetItemParents(id)}`) .then(({ data }) => data); diff --git a/src/item/hooks.test.ts b/src/item/hooks.test.ts index a3e67e25..889005d6 100644 --- a/src/item/hooks.test.ts +++ b/src/item/hooks.test.ts @@ -236,20 +236,6 @@ describe('useParents', () => { } }); - it(`providing path can deduce empty array`, async () => { - const { data, isFetched } = await mockHook({ - hook: () => hooks.useParents({ id: childItem.id, path: 'some-id' }), - endpoints: [], - wrapper, - }); - - expect(data).toHaveLength(0); - expect(isFetched).toBeTruthy(); - expect( - queryClient.getQueryData(itemKeys.single(childItem.id).parents), - ).toHaveLength(0); - }); - it(`Unauthorized`, async () => { // build endpoint for each item const endpoints = [ diff --git a/src/item/hooks.ts b/src/item/hooks.ts index 2e0cb081..c0c8da85 100644 --- a/src/item/hooks.ts +++ b/src/item/hooks.ts @@ -119,18 +119,9 @@ const config = ( /** * return parents for given item id * @param id {string} item id - * @param path {string} item path, used to prevent fetching if no parent is defined * @returns immutable list of parent items */ - useParents: ({ - id, - path, - enabled, - }: { - id?: UUID; - path?: string; - enabled?: boolean; - }) => { + useParents: ({ id, enabled }: { id?: UUID; enabled?: boolean }) => { return useQuery({ queryKey: itemKeys.single(id).parents, queryFn: async () => { @@ -138,7 +129,7 @@ const config = ( throw new UndefinedArgument(); } - return Api.getParents({ id, path }, queryConfig); + return Api.getParents({ id }, queryConfig); }, ...defaultQueryOptions, enabled: enabled && Boolean(id),