Removing Prisma and Grapql-nestjs-prisma resolvers (#2574)
* Some cleaning * Fix seeds * Fix all sign in, sign up flow and apiKey optimistic rendering * Fix
This commit is contained in:
@ -7,7 +7,6 @@ import { tokenPairState } from '@/auth/states/tokenPairState';
|
||||
import { isDebugModeState } from '@/client-config/states/isDebugModeState';
|
||||
import { AppPath } from '@/types/AppPath';
|
||||
import { REACT_APP_SERVER_BASE_URL } from '~/config';
|
||||
import { ActivityTarget } from '~/generated/graphql';
|
||||
import { useIsMatchingLocation } from '~/hooks/useIsMatchingLocation';
|
||||
import { useUpdateEffect } from '~/hooks/useUpdateEffect';
|
||||
|
||||
@ -25,23 +24,7 @@ export const useApolloFactory = () => {
|
||||
const apolloClient = useMemo(() => {
|
||||
apolloRef.current = new ApolloFactory({
|
||||
uri: `${REACT_APP_SERVER_BASE_URL}/graphql`,
|
||||
cache: new InMemoryCache({
|
||||
typePolicies: {
|
||||
Activity: {
|
||||
fields: {
|
||||
activityTargets: {
|
||||
merge: (
|
||||
_existing: ActivityTarget[] = [],
|
||||
incoming: ActivityTarget[],
|
||||
) => {
|
||||
return [...incoming];
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
ViewField: { keyFields: ['viewId', 'key'] },
|
||||
},
|
||||
}),
|
||||
cache: new InMemoryCache(),
|
||||
defaultOptions: {
|
||||
query: {
|
||||
fetchPolicy: 'cache-first',
|
||||
|
||||
@ -7,19 +7,11 @@ import {
|
||||
import { isNonEmptyArray } from '@sniptt/guards';
|
||||
import { useRecoilCallback } from 'recoil';
|
||||
|
||||
import { GET_COMPANIES } from '@/companies/graphql/queries/getCompanies';
|
||||
import {
|
||||
EMPTY_QUERY,
|
||||
useFindOneObjectMetadataItem,
|
||||
} from '@/object-metadata/hooks/useFindOneObjectMetadataItem';
|
||||
import { ObjectMetadataItem } from '@/object-metadata/types/ObjectMetadataItem';
|
||||
import { GET_PEOPLE } from '@/people/graphql/queries/getPeople';
|
||||
import { GET_API_KEYS } from '@/settings/developers/graphql/queries/getApiKeys';
|
||||
import {
|
||||
GetApiKeysQuery,
|
||||
GetCompaniesQuery,
|
||||
GetPeopleQuery,
|
||||
} from '~/generated/graphql';
|
||||
|
||||
import { optimisticEffectState } from '../states/optimisticEffectState';
|
||||
import { OptimisticEffect } from '../types/internal/OptimisticEffect';
|
||||
@ -59,7 +51,6 @@ export const useOptimisticEffect = ({
|
||||
newData,
|
||||
query,
|
||||
variables,
|
||||
isUsingFlexibleBackend,
|
||||
objectMetadataItem,
|
||||
}: {
|
||||
cache: ApolloCache<unknown>;
|
||||
@ -69,7 +60,7 @@ export const useOptimisticEffect = ({
|
||||
isUsingFlexibleBackend?: boolean;
|
||||
objectMetadataItem?: ObjectMetadataItem;
|
||||
}) => {
|
||||
if (isUsingFlexibleBackend && objectMetadataItem) {
|
||||
if (objectMetadataItem) {
|
||||
const existingData = cache.readQuery({
|
||||
query: findManyQuery,
|
||||
variables,
|
||||
@ -104,50 +95,6 @@ export const useOptimisticEffect = ({
|
||||
if (!existingData) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (query === GET_PEOPLE) {
|
||||
cache.writeQuery({
|
||||
query,
|
||||
variables,
|
||||
data: {
|
||||
people: definition.resolver({
|
||||
currentData: (existingData as GetPeopleQuery).people as T[],
|
||||
newData: newData as T[],
|
||||
variables,
|
||||
}),
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
if (query === GET_COMPANIES) {
|
||||
cache.writeQuery({
|
||||
query,
|
||||
variables,
|
||||
data: {
|
||||
companies: definition.resolver({
|
||||
currentData: (existingData as GetCompaniesQuery)
|
||||
.companies as T[],
|
||||
newData: newData as T[],
|
||||
variables,
|
||||
}),
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
if (query === GET_API_KEYS) {
|
||||
cache.writeQuery({
|
||||
query,
|
||||
variables,
|
||||
data: {
|
||||
findManyApiKey: definition.resolver({
|
||||
currentData: (existingData as GetApiKeysQuery)
|
||||
.findManyApiKey as T[],
|
||||
newData: newData as T[],
|
||||
variables,
|
||||
}),
|
||||
},
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const optimisticEffect = {
|
||||
|
||||
Reference in New Issue
Block a user