Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
"semantic-release": "25.0.3"
},
"dependencies": {
"@apollo/client": "3.10.8",
"@apollo/client": "3.14.1",
"@emotion/react": "11.14.0",
"@emotion/styled": "11.14.1",
"@zextras/carbonio-design-system": "12.0.4",
Expand Down
24 changes: 9 additions & 15 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/apollo/cacheUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { type Task } from '../gql/types';

export const removeTaskFromList: (
...tasks: Pick<Task, '__typename' | 'id'>[]
) => Modifier<readonly Reference[] | Reference> =
) => Modifier<readonly Reference[]> =
(...tasks) =>
(existing, { toReference }) => {
if (existing && Array.isArray(existing)) {
Expand All @@ -24,7 +24,7 @@ export const removeTaskFromList: (

export const addTaskToList: (
task: Pick<Task, '__typename' | 'id'>
) => Modifier<readonly Reference[] | Reference> =
) => Modifier<readonly Reference[]> =
(task) =>
(existing, { toReference, readField }) => {
const newTaskRef = toReference(task);
Expand Down
2 changes: 1 addition & 1 deletion src/apollo/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const buildClient: () => ApolloClient<NormalizedCacheObject> = () => {

apolloClient = new ApolloClient<NormalizedCacheObject>({
cache,
connectToDevTools: process.env.NODE_ENV !== 'production',
devtools: { enabled: process.env.NODE_ENV !== 'production' },
link: httpLink
});
}
Expand Down
3 changes: 2 additions & 1 deletion src/components/RemindersManager.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import React from 'react';

import { type Reference } from '@apollo/client';
import { faker } from '@faker-js/faker';
import { act, screen, waitFor } from '@testing-library/react';
import * as carbonioShellUi from '@zextras/carbonio-shell-ui';
Expand Down Expand Up @@ -61,7 +62,7 @@ describe('Reminders manager', () => {
data: updateTask
});
if (updateTask.status === Status.Complete) {
global.apolloClient.cache.modify({
global.apolloClient.cache.modify<{ findTasks: Reference[] }>({
fields: {
findTasks: removeTaskFromList(updateTask)
}
Expand Down
6 changes: 2 additions & 4 deletions src/components/RemindersManager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,7 @@ export const RemindersManager = (): React.JSX.Element => {
errorPolicy: 'all'
});
// lazy query used to load data at first load
const [findRemindersLazyQuery] = useLazyQuery(FindTasksDocument, {
variables: { status: Status.Open }
});
const [findRemindersLazyQuery] = useLazyQuery(FindTasksDocument);
const [updateTaskStatus] = useMutation(UpdateTaskStatusDocument);
const [isModalOpen, setIsModalOpen] = useState<boolean>(false);
// Array of group of reminders.
Expand Down Expand Up @@ -394,7 +392,7 @@ export const RemindersManager = (): React.JSX.Element => {
useEffect(() => {
// init reminders manager by requesting all tasks with the lazy query
remindersByDateRef.current = {};
findRemindersLazyQuery()
findRemindersLazyQuery({ variables: { status: Status.Open } })
.then((result) => {
if (result?.data?.findTasks) {
registerRemindersFromTasks(result.data.findTasks);
Expand Down
4 changes: 2 additions & 2 deletions src/hooks/useTrashAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import { useCallback } from 'react';

import { type FetchResult, useMutation } from '@apollo/client';
import { type FetchResult, type Reference, useMutation } from '@apollo/client';

import { useActiveItem } from './useActiveItem';
import { removeTaskFromList } from '../apollo/cacheUtils';
Expand All @@ -27,7 +27,7 @@ export const useTrashAction = (taskId: string): TrashActionFn => {
trashTask({
update: (cache, { data }) => {
if (data?.trashTask) {
cache.modify({
cache.modify<{ findTasks: Reference[] }>({
fields: {
findTasks: removeTaskFromList({ id: data.trashTask, __typename: 'Task' })
}
Expand Down
7 changes: 3 additions & 4 deletions src/utils/testUtils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import React, { type ReactElement, useMemo } from 'react';

import { ApolloProvider } from '@apollo/client';
import { MockedProvider } from '@apollo/client/testing';
import { MockedProvider, type MockedResponse } from '@apollo/client/testing';
import {
act,
type ByRoleMatcher,
Expand All @@ -30,7 +30,6 @@ import { I18nextProvider } from 'react-i18next';
import { MemoryRouter } from 'react-router-dom';
import { type Mock as ViMock } from 'vitest';

import { type Mock } from '../mocks/utils';
import { StyledWrapper } from '../providers/StyledWrapper';

export type UserEvent = ReturnType<(typeof userEvent)['setup']> & {
Expand Down Expand Up @@ -105,15 +104,15 @@ export const getAppI18n = (): i18n => {
interface WrapperProps {
children?: React.ReactNode | undefined;
initialRouterEntries?: string[];
mocks?: Mock[];
mocks?: MockedResponse[];
}

const ApolloProviderWrapper = ({
children,
mocks
}: {
children: React.ReactNode;
mocks: Mock[] | undefined;
mocks: MockedResponse[] | undefined;
}): React.JSX.Element =>
mocks ? (
<MockedProvider mocks={mocks} cache={global.apolloClient.cache}>
Expand Down
4 changes: 2 additions & 2 deletions src/views/board/NewTaskBoard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
import React, { useCallback, useMemo } from 'react';

import { useMutation, useQuery } from '@apollo/client';
import { type Reference, useMutation, useQuery } from '@apollo/client';
import { Banner, useSnackbar } from '@zextras/carbonio-design-system';
import { t, useBoardHooks } from '@zextras/carbonio-shell-ui';
import { filter, trim } from 'lodash';
Expand Down Expand Up @@ -68,7 +68,7 @@ const NewTaskBoard = (): React.JSX.Element => {
},
update(cache, { data }) {
if (data?.createTask) {
cache.modify({
cache.modify<{ findTasks: Reference[] }>({
fields: {
findTasks: addTaskToList(data.createTask)
}
Expand Down