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:
@ -13,6 +13,7 @@ import { SettingsPageContainer } from '@/settings/components/SettingsPageContain
|
||||
import { ApiKeyInput } from '@/settings/developers/components/ApiKeyInput';
|
||||
import { useGeneratedApiKeys } from '@/settings/developers/hooks/useGeneratedApiKeys';
|
||||
import { generatedApiKeyFamilyState } from '@/settings/developers/states/generatedApiKeyFamilyState';
|
||||
import { ApiKey } from '@/settings/developers/types/ApiKey';
|
||||
import { computeNewExpirationDate } from '@/settings/developers/utils/compute-new-expiration-date';
|
||||
import { formatExpiration } from '@/settings/developers/utils/format-expiration';
|
||||
import { IconRepeat, IconSettings, IconTrash } from '@/ui/display/icon';
|
||||
@ -22,7 +23,7 @@ import { TextInput } from '@/ui/input/components/TextInput';
|
||||
import { SubMenuTopBarContainer } from '@/ui/layout/page/SubMenuTopBarContainer';
|
||||
import { Section } from '@/ui/layout/section/components/Section';
|
||||
import { Breadcrumb } from '@/ui/navigation/bread-crumb/components/Breadcrumb';
|
||||
import { ApiKey, useGenerateOneApiKeyTokenMutation } from '~/generated/graphql';
|
||||
import { useGenerateApiKeyTokenMutation } from '~/generated/graphql';
|
||||
|
||||
const StyledInfo = styled.span`
|
||||
color: ${({ theme }) => theme.font.color.light};
|
||||
@ -48,18 +49,18 @@ export const SettingsDevelopersApiKeyDetail = () => {
|
||||
);
|
||||
const { performOptimisticEvict } = useOptimisticEvict();
|
||||
|
||||
const [generateOneApiKeyToken] = useGenerateOneApiKeyTokenMutation();
|
||||
const [generateOneApiKeyToken] = useGenerateApiKeyTokenMutation();
|
||||
const { createOneObject: createOneApiKey } = useCreateOneObjectRecord<ApiKey>(
|
||||
{
|
||||
objectNameSingular: 'apiKeyV2',
|
||||
objectNameSingular: 'apiKey',
|
||||
},
|
||||
);
|
||||
const { updateOneObject: updateApiKey } = useUpdateOneObjectRecord<ApiKey>({
|
||||
objectNameSingular: 'apiKeyV2',
|
||||
objectNameSingular: 'apiKey',
|
||||
});
|
||||
|
||||
const { object: apiKeyData } = useFindOneObjectRecord({
|
||||
objectNameSingular: 'apiKeyV2',
|
||||
objectNameSingular: 'apiKey',
|
||||
objectRecordId: apiKeyId,
|
||||
});
|
||||
|
||||
@ -68,7 +69,7 @@ export const SettingsDevelopersApiKeyDetail = () => {
|
||||
idToUpdate: apiKeyId,
|
||||
input: { revokedAt: DateTime.now().toString() },
|
||||
});
|
||||
performOptimisticEvict('ApiKeyV2', 'id', apiKeyId);
|
||||
performOptimisticEvict('ApiKey', 'id', apiKeyId);
|
||||
if (redirect) {
|
||||
navigate('/settings/developers/api-keys');
|
||||
}
|
||||
@ -89,16 +90,13 @@ export const SettingsDevelopersApiKeyDetail = () => {
|
||||
|
||||
const tokenData = await generateOneApiKeyToken({
|
||||
variables: {
|
||||
data: {
|
||||
id: newApiKey.id,
|
||||
expiresAt: newApiKey.expiresAt,
|
||||
name: newApiKey.name, // TODO update typing to remove useless name param here
|
||||
},
|
||||
apiKeyId: newApiKey.id,
|
||||
expiresAt: newApiKey?.expiresAt,
|
||||
},
|
||||
});
|
||||
return {
|
||||
id: newApiKey.id,
|
||||
token: tokenData.data?.generateApiKeyV2Token.token,
|
||||
token: tokenData.data?.generateApiKeyToken.token,
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@ -45,14 +45,14 @@ export const SettingsDevelopersApiKeys = () => {
|
||||
|
||||
const [apiKeys, setApiKeys] = useState<Array<ApiFieldItem>>([]);
|
||||
const { registerOptimisticEffect } = useOptimisticEffect({
|
||||
objectNameSingular: 'apiKeyV2',
|
||||
objectNameSingular: 'apiKey',
|
||||
});
|
||||
const { foundObjectMetadataItem } = useFindOneObjectMetadataItem({
|
||||
objectNameSingular: 'apiKeyV2',
|
||||
objectNameSingular: 'apiKey',
|
||||
});
|
||||
const filter = { revokedAt: { eq: null } };
|
||||
useFindManyObjectRecords({
|
||||
objectNamePlural: 'apiKeysV2',
|
||||
objectNamePlural: 'apiKeys',
|
||||
filter,
|
||||
onCompleted: (data) => {
|
||||
setApiKeys(
|
||||
@ -66,7 +66,7 @@ export const SettingsDevelopersApiKeys = () => {
|
||||
);
|
||||
if (foundObjectMetadataItem) {
|
||||
registerOptimisticEffect({
|
||||
variables: { filter },
|
||||
variables: { filter, first: 30, orderBy: {} },
|
||||
definition: getRecordOptimisticEffectDefinition({
|
||||
objectMetadataItem: foundObjectMetadataItem,
|
||||
}),
|
||||
|
||||
@ -8,6 +8,7 @@ import { SettingsHeaderContainer } from '@/settings/components/SettingsHeaderCon
|
||||
import { SettingsPageContainer } from '@/settings/components/SettingsPageContainer';
|
||||
import { ExpirationDates } from '@/settings/developers/constants/expirationDates';
|
||||
import { useGeneratedApiKeys } from '@/settings/developers/hooks/useGeneratedApiKeys';
|
||||
import { ApiKey } from '@/settings/developers/types/ApiKey';
|
||||
import { IconSettings } from '@/ui/display/icon';
|
||||
import { H2Title } from '@/ui/display/typography/components/H2Title';
|
||||
import { Select } from '@/ui/input/components/Select';
|
||||
@ -15,10 +16,10 @@ import { TextInput } from '@/ui/input/components/TextInput';
|
||||
import { SubMenuTopBarContainer } from '@/ui/layout/page/SubMenuTopBarContainer';
|
||||
import { Section } from '@/ui/layout/section/components/Section';
|
||||
import { Breadcrumb } from '@/ui/navigation/bread-crumb/components/Breadcrumb';
|
||||
import { ApiKey, useGenerateOneApiKeyTokenMutation } from '~/generated/graphql';
|
||||
import { useGenerateApiKeyTokenMutation } from '~/generated/graphql';
|
||||
|
||||
export const SettingsDevelopersApiKeysNew = () => {
|
||||
const [generateOneApiKeyToken] = useGenerateOneApiKeyTokenMutation();
|
||||
const [generateOneApiKeyToken] = useGenerateApiKeyTokenMutation();
|
||||
const navigate = useNavigate();
|
||||
const setGeneratedApi = useGeneratedApiKeys();
|
||||
const [formValues, setFormValues] = useState<{
|
||||
@ -30,14 +31,12 @@ export const SettingsDevelopersApiKeysNew = () => {
|
||||
});
|
||||
|
||||
const { createOneObject: createOneApiKey } = useCreateOneObjectRecord<ApiKey>(
|
||||
{
|
||||
objectNameSingular: 'apiKeyV2',
|
||||
},
|
||||
{ objectNameSingular: 'apiKey' },
|
||||
);
|
||||
const onSave = async () => {
|
||||
const expiresAt = formValues.expirationDate
|
||||
? DateTime.now().plus({ days: formValues.expirationDate }).toString()
|
||||
: null;
|
||||
const expiresAt = DateTime.now()
|
||||
.plus({ days: formValues.expirationDate ?? 30 })
|
||||
.toString();
|
||||
const newApiKey = await createOneApiKey?.({
|
||||
name: formValues.name,
|
||||
expiresAt,
|
||||
@ -49,15 +48,12 @@ export const SettingsDevelopersApiKeysNew = () => {
|
||||
|
||||
const tokenData = await generateOneApiKeyToken({
|
||||
variables: {
|
||||
data: {
|
||||
id: newApiKey.id,
|
||||
expiresAt: newApiKey.expiresAt,
|
||||
name: newApiKey.name, // TODO update typing to remove useless name param here
|
||||
},
|
||||
apiKeyId: newApiKey.id,
|
||||
expiresAt: expiresAt,
|
||||
},
|
||||
});
|
||||
if (tokenData.data?.generateApiKeyV2Token) {
|
||||
setGeneratedApi(newApiKey.id, tokenData.data.generateApiKeyV2Token.token);
|
||||
if (tokenData.data?.generateApiKeyToken) {
|
||||
setGeneratedApi(newApiKey.id, tokenData.data.generateApiKeyToken.token);
|
||||
navigate(`/settings/developers/api-keys/${newApiKey.id}`);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user