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:
Charles Bochet
2023-11-19 18:25:47 +01:00
committed by GitHub
parent 18dac1a2b6
commit f5e1d7825a
616 changed files with 2220 additions and 23073 deletions

View File

@ -140,7 +140,7 @@ export const SettingsObjectFieldPreview = ({
entityId,
fieldDefinition: {
type: parseFieldType(fieldMetadata.type),
Icon: FieldIcon,
iconName: 'FieldIcon',
fieldMetadataId: fieldMetadata.id || '',
label: fieldMetadata.label,
metadata: { fieldName },

View File

@ -13,7 +13,7 @@ import {
IconUser,
} from '@/ui/display/icon';
import { IconComponent } from '@/ui/display/icon/types/IconComponent';
import { CurrencyCode, FieldMetadataType } from '~/generated-metadata/graphql';
import { FieldMetadataType } from '~/generated-metadata/graphql';
const defaultDateValue = new Date();
defaultDateValue.setFullYear(defaultDateValue.getFullYear() + 2);
@ -61,7 +61,7 @@ export const dataTypes: Record<
[FieldMetadataType.Currency]: {
label: 'Currency',
Icon: IconCoins,
defaultValue: { amountMicros: 2000000000, currencyCode: CurrencyCode.Usd },
defaultValue: { amountMicros: 2000000000, currencyCode: 'USD' },
},
[FieldMetadataType.Relation]: {
label: 'Relation',

View File

@ -55,7 +55,9 @@ export const SettingsObjectItemTableRow = ({
<Tag color="blue" text="Standard" />
)}
</TableCell>
<TableCell align="right">{objectItem.fields.length}</TableCell>
<TableCell align="right">
{objectItem.fields.filter((field) => !field.isSystem).length}
</TableCell>
<TableCell align="right">{objects.length}</TableCell>
<StyledActionTableCell>{action}</StyledActionTableCell>
</StyledObjectTableRow>

View File

@ -1,9 +0,0 @@
import { gql } from '@apollo/client';
export const DELETE_ONE_API_KEY = gql`
mutation DeleteOneApiKey($apiKeyId: String!) {
revokeOneApiKey(where: { id: $apiKeyId }) {
id
}
}
`;

View File

@ -1,9 +0,0 @@
import { gql } from '@apollo/client';
export const GENERATE_ONE_API_KEY_TOKEN = gql`
mutation GenerateOneApiKeyToken($data: ApiKeyCreateInput!) {
generateApiKeyV2Token(data: $data) {
token
}
}
`;

View File

@ -1,13 +0,0 @@
import { gql } from '@apollo/client';
export const INSERT_ONE_API_KEY = gql`
mutation InsertOneApiKey($data: ApiKeyCreateInput!) {
createOneApiKey(data: $data) {
id
name
token
createdAt
expiresAt
}
}
`;

View File

@ -1,12 +0,0 @@
import { gql } from '@apollo/client';
export const GET_API_KEY = gql`
query GetApiKey($apiKeyId: String!) {
findManyApiKey(where: { id: { equals: $apiKeyId } }) {
id
name
expiresAt
createdAt
}
}
`;

View File

@ -1,12 +0,0 @@
import { gql } from '@apollo/client';
export const GET_API_KEYS = gql`
query GetApiKeys {
findManyApiKey {
id
name
expiresAt
createdAt
}
}
`;

View File

@ -1,17 +0,0 @@
import { GET_API_KEYS } from '@/settings/developers/graphql/queries/getApiKeys';
import { ApiKey } from '~/generated/graphql';
export const getApiKeysOptimisticEffectDefinition = {
key: 'generic-entity-table-data-api-keys',
typename: 'ApiKey',
query: GET_API_KEYS,
resolver: ({
currentData,
newData,
}: {
currentData: ApiKey[];
newData: ApiKey[];
}) => {
return [...newData, ...currentData];
},
};

View File

@ -0,0 +1,8 @@
export type ApiKey = {
id: string;
createdAt: string;
updatedAt: string;
deletedAt: string | null;
name: string;
expiresAt: string;
};

View File

@ -1,5 +1,5 @@
import { ApiFieldItem } from '@/settings/developers/types/ApiFieldItem';
import { ApiKey } from '~/generated/graphql';
import { ApiKey } from '@/settings/developers/types/ApiKey';
import { beautifyDateDiff } from '~/utils/date-utils';
export const formatExpiration = (

View File

@ -42,7 +42,7 @@ export const NameFields = ({
const { updateOneObject, objectNotFoundInMetadata } =
useUpdateOneObjectRecord({
objectNameSingular: 'workspaceMemberV2',
objectNameSingular: 'workspaceMember',
});
// TODO: Enhance this with react-web-hook-form (https://www.react-hook-form.com)

View File

@ -21,7 +21,7 @@ export const ProfilePictureUploader = () => {
const { updateOneObject, objectNotFoundInMetadata } =
useUpdateOneObjectRecord({
objectNameSingular: 'workspaceMemberV2',
objectNameSingular: 'workspaceMember',
});
const handleUpload = async (file: File) => {

View File

@ -14,7 +14,7 @@ export const ToggleField = () => {
const { updateOneObject, objectNotFoundInMetadata } =
useUpdateOneObjectRecord({
objectNameSingular: 'workspaceMemberV2',
objectNameSingular: 'workspaceMember',
});
const handleChange = async (value: boolean) => {

View File

@ -1,12 +1,10 @@
import { useCallback, useEffect, useState } from 'react';
import { getOperationName } from '@apollo/client/utilities';
import styled from '@emotion/styled';
import debounce from 'lodash.debounce';
import { useRecoilValue } from 'recoil';
import { currentWorkspaceState } from '@/auth/states/currentWorkspaceState';
import { TextInput } from '@/ui/input/components/TextInput';
import { GET_CURRENT_USER } from '@/users/graphql/queries/getCurrentUser';
import { useUpdateWorkspaceMutation } from '~/generated/graphql';
import { logError } from '~/utils/logError';
@ -48,12 +46,10 @@ export const NameField = ({
try {
const { data, errors } = await updateWorkspace({
variables: {
data: {
input: {
displayName: name,
},
},
refetchQueries: [getOperationName(GET_CURRENT_USER) ?? ''],
awaitRefetchQueries: true,
});
if (errors || !data?.updateWorkspace) {

View File

@ -4,13 +4,13 @@ import { currentWorkspaceState } from '@/auth/states/currentWorkspaceState';
import { ImageInput } from '@/ui/input/components/ImageInput';
import { getImageAbsoluteURIOrBase64 } from '@/users/utils/getProfilePictureAbsoluteURI';
import {
useRemoveWorkspaceLogoMutation,
useUpdateWorkspaceMutation,
useUploadWorkspaceLogoMutation,
} from '~/generated/graphql';
export const WorkspaceLogoUploader = () => {
const [uploadLogo] = useUploadWorkspaceLogoMutation();
const [removeLogo] = useRemoveWorkspaceLogoMutation();
const [updateWorkspce] = useUpdateWorkspaceMutation();
const [currentWorkspace, setCurrentWorkspace] = useRecoilState(
currentWorkspaceState,
);
@ -39,7 +39,12 @@ export const WorkspaceLogoUploader = () => {
if (!currentWorkspace?.id) {
throw new Error('Workspace id not found');
}
await removeLogo({
await updateWorkspce({
variables: {
input: {
logo: null,
},
},
onCompleted: () => {
setCurrentWorkspace({
...currentWorkspace,