Separate system operations from core objects in GraphQL endpoints (#12977)
Moves system-level operations (auth, billing, admin) to use the /metadata endpoint instead of /graphql. This cleans up the endpoint separation so /graphql is purely for core objects (Company, People, etc.) and /metadata handles all system operations. Part of prep work for webhook/API key core migration.
This commit is contained in:
@ -5,20 +5,43 @@ module.exports = {
|
||||
(process.env.REACT_APP_SERVER_BASE_URL ?? 'http://localhost:3000') +
|
||||
'/metadata',
|
||||
documents: [
|
||||
'./src/modules/databases/graphql/**/*.ts',
|
||||
'./src/modules/object-metadata/graphql/*.ts',
|
||||
'./src/modules/settings/serverless-functions/graphql/**/*.ts',
|
||||
'./src/modules/object-record/graphql/*.tsx',
|
||||
'./src/modules/metadata/graphql/*.ts',
|
||||
'./src/modules/auth/graphql/**/*.{ts,tsx}',
|
||||
'./src/modules/users/graphql/**/*.{ts,tsx}',
|
||||
|
||||
'./src/modules/workspace/graphql/**/*.{ts,tsx}',
|
||||
'./src/modules/workspace-member/graphql/**/*.{ts,tsx}',
|
||||
'./src/modules/workspace-invitation/graphql/**/*.{ts,tsx}',
|
||||
|
||||
'./src/modules/billing/graphql/**/*.{ts,tsx}',
|
||||
'./src/modules/settings/**/graphql/**/*.{ts,tsx}',
|
||||
|
||||
'./src/modules/databases/graphql/**/*.{ts,tsx}',
|
||||
'./src/modules/workflow/**/graphql/**/*.{ts,tsx}',
|
||||
'./src/modules/analytics/graphql/**/*.{ts,tsx}',
|
||||
'./src/modules/object-metadata/graphql/**/*.{ts,tsx}',
|
||||
'./src/modules/attachments/graphql/**/*.{ts,tsx}',
|
||||
'./src/modules/onboarding/graphql/**/*.{ts,tsx}',
|
||||
|
||||
'!./src/**/*.test.{ts,tsx}',
|
||||
'!./src/**/*.stories.{ts,tsx}',
|
||||
'!./src/**/__mocks__/*.ts',
|
||||
],
|
||||
overwrite: true,
|
||||
generates: {
|
||||
'./src/generated-metadata/': {
|
||||
preset: 'client',
|
||||
presetConfig: {
|
||||
fragmentMasking: false,
|
||||
},
|
||||
'./src/generated-metadata/graphql.ts': {
|
||||
plugins: [
|
||||
'typescript',
|
||||
'typescript-operations',
|
||||
'typescript-react-apollo',
|
||||
],
|
||||
config: {
|
||||
skipTypename: false,
|
||||
withHooks: true,
|
||||
withHOC: false,
|
||||
withComponent: false,
|
||||
scalars: {
|
||||
DateTime: 'string',
|
||||
},
|
||||
namingConvention: { enumValues: 'keep' },
|
||||
},
|
||||
},
|
||||
|
||||
@ -5,20 +5,27 @@ module.exports = {
|
||||
(process.env.REACT_APP_SERVER_BASE_URL ?? 'http://localhost:3000') +
|
||||
'/graphql',
|
||||
documents: [
|
||||
'!./src/modules/databases/**',
|
||||
'!./src/modules/object-metadata/**',
|
||||
'!./src/modules/object-record/**',
|
||||
'!./src/modules/settings/serverless-functions/**',
|
||||
'!./src/modules/settings/accounts/hooks/**',
|
||||
'./src/modules/**/*.tsx',
|
||||
'./src/modules/**/*.ts',
|
||||
'!./src/**/*.test.tsx',
|
||||
'!./src/**/*.stories.tsx',
|
||||
'./src/modules/activities/graphql/**/*.{ts,tsx}',
|
||||
'./src/modules/companies/graphql/**/*.{ts,tsx}',
|
||||
'./src/modules/people/graphql/**/*.{ts,tsx}',
|
||||
'./src/modules/opportunities/graphql/**/*.{ts,tsx}',
|
||||
|
||||
'./src/modules/search/graphql/**/*.{ts,tsx}',
|
||||
'./src/modules/views/graphql/**/*.{ts,tsx}',
|
||||
'./src/modules/favorites/graphql/**/*.{ts,tsx}',
|
||||
'./src/modules/spreadsheet-import/graphql/**/*.{ts,tsx}',
|
||||
'./src/modules/command-menu/graphql/**/*.{ts,tsx}',
|
||||
|
||||
'./src/modules/prefetch/graphql/**/*.{ts,tsx}',
|
||||
'./src/modules/subscription/graphql/**/*.{ts,tsx}',
|
||||
|
||||
'!./src/**/*.test.{ts,tsx}',
|
||||
'!./src/**/*.stories.{ts,tsx}',
|
||||
'!./src/**/__mocks__/*.ts',
|
||||
],
|
||||
overwrite: true,
|
||||
generates: {
|
||||
'./src/generated/graphql.tsx': {
|
||||
'./src/generated/graphql.ts': {
|
||||
plugins: [
|
||||
'typescript',
|
||||
'typescript-operations',
|
||||
|
||||
@ -1,177 +0,0 @@
|
||||
/* eslint-disable */
|
||||
import * as types from './graphql';
|
||||
import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core';
|
||||
|
||||
/**
|
||||
* Map of all GraphQL operations in the project.
|
||||
*
|
||||
* This map has several performance disadvantages:
|
||||
* 1. It is not tree-shakeable, so it will include all operations in the project.
|
||||
* 2. It is not minifiable, so the string of a GraphQL query will be multiple times inside the bundle.
|
||||
* 3. It does not support dead code elimination, so it will add unused operations.
|
||||
*
|
||||
* Therefore it is highly recommended to use the babel or swc plugin for production.
|
||||
*/
|
||||
const documents = {
|
||||
"\n fragment RemoteServerFields on RemoteServer {\n id\n createdAt\n foreignDataWrapperId\n foreignDataWrapperOptions\n foreignDataWrapperType\n userMappingOptions {\n user\n }\n updatedAt\n schema\n label\n }\n": types.RemoteServerFieldsFragmentDoc,
|
||||
"\n fragment RemoteTableFields on RemoteTable {\n id\n name\n schema\n status\n schemaPendingUpdates\n }\n": types.RemoteTableFieldsFragmentDoc,
|
||||
"\n \n mutation createServer($input: CreateRemoteServerInput!) {\n createOneRemoteServer(input: $input) {\n ...RemoteServerFields\n }\n }\n": types.CreateServerDocument,
|
||||
"\n mutation deleteServer($input: RemoteServerIdInput!) {\n deleteOneRemoteServer(input: $input) {\n id\n }\n }\n": types.DeleteServerDocument,
|
||||
"\n \n mutation syncRemoteTable($input: RemoteTableInput!) {\n syncRemoteTable(input: $input) {\n ...RemoteTableFields\n }\n }\n": types.SyncRemoteTableDocument,
|
||||
"\n \n mutation syncRemoteTableSchemaChanges($input: RemoteTableInput!) {\n syncRemoteTableSchemaChanges(input: $input) {\n ...RemoteTableFields\n }\n }\n": types.SyncRemoteTableSchemaChangesDocument,
|
||||
"\n \n mutation unsyncRemoteTable($input: RemoteTableInput!) {\n unsyncRemoteTable(input: $input) {\n ...RemoteTableFields\n }\n }\n": types.UnsyncRemoteTableDocument,
|
||||
"\n \n mutation updateServer($input: UpdateRemoteServerInput!) {\n updateOneRemoteServer(input: $input) {\n ...RemoteServerFields\n }\n }\n": types.UpdateServerDocument,
|
||||
"\n \n query GetManyDatabaseConnections($input: RemoteServerTypeInput!) {\n findManyRemoteServersByType(input: $input) {\n ...RemoteServerFields\n }\n }\n": types.GetManyDatabaseConnectionsDocument,
|
||||
"\n \n query GetManyRemoteTables($input: FindManyRemoteTablesInput!) {\n findDistantTablesWithStatus(input: $input) {\n ...RemoteTableFields\n }\n }\n": types.GetManyRemoteTablesDocument,
|
||||
"\n \n query GetOneDatabaseConnection($input: RemoteServerIdInput!) {\n findOneRemoteServerById(input: $input) {\n ...RemoteServerFields\n }\n }\n": types.GetOneDatabaseConnectionDocument,
|
||||
"\n mutation CreateOneObjectMetadataItem($input: CreateOneObjectInput!) {\n createOneObject(input: $input) {\n id\n dataSourceId\n nameSingular\n namePlural\n labelSingular\n labelPlural\n description\n icon\n isCustom\n isActive\n isSearchable\n createdAt\n updatedAt\n labelIdentifierFieldMetadataId\n imageIdentifierFieldMetadataId\n isLabelSyncedWithName\n }\n }\n": types.CreateOneObjectMetadataItemDocument,
|
||||
"\n mutation CreateOneFieldMetadataItem($input: CreateOneFieldMetadataInput!) {\n createOneField(input: $input) {\n id\n type\n name\n label\n description\n icon\n isCustom\n isActive\n isNullable\n createdAt\n updatedAt\n settings\n defaultValue\n options\n isLabelSyncedWithName\n }\n }\n": types.CreateOneFieldMetadataItemDocument,
|
||||
"\n mutation UpdateOneFieldMetadataItem(\n $idToUpdate: UUID!\n $updatePayload: UpdateFieldInput!\n ) {\n updateOneField(input: { id: $idToUpdate, update: $updatePayload }) {\n id\n type\n name\n label\n description\n icon\n isCustom\n isActive\n isNullable\n createdAt\n updatedAt\n settings\n isLabelSyncedWithName\n }\n }\n": types.UpdateOneFieldMetadataItemDocument,
|
||||
"\n mutation UpdateOneObjectMetadataItem(\n $idToUpdate: UUID!\n $updatePayload: UpdateObjectPayload!\n ) {\n updateOneObject(input: { id: $idToUpdate, update: $updatePayload }) {\n id\n dataSourceId\n nameSingular\n namePlural\n labelSingular\n labelPlural\n description\n icon\n isCustom\n isActive\n isSearchable\n createdAt\n updatedAt\n labelIdentifierFieldMetadataId\n imageIdentifierFieldMetadataId\n isLabelSyncedWithName\n }\n }\n": types.UpdateOneObjectMetadataItemDocument,
|
||||
"\n mutation DeleteOneObjectMetadataItem($idToDelete: UUID!) {\n deleteOneObject(input: { id: $idToDelete }) {\n id\n dataSourceId\n nameSingular\n namePlural\n labelSingular\n labelPlural\n description\n icon\n isCustom\n isActive\n isSearchable\n createdAt\n updatedAt\n labelIdentifierFieldMetadataId\n imageIdentifierFieldMetadataId\n isLabelSyncedWithName\n }\n }\n": types.DeleteOneObjectMetadataItemDocument,
|
||||
"\n mutation DeleteOneFieldMetadataItem($idToDelete: UUID!) {\n deleteOneField(input: { id: $idToDelete }) {\n id\n type\n name\n label\n description\n icon\n isCustom\n isActive\n isNullable\n createdAt\n updatedAt\n settings\n }\n }\n": types.DeleteOneFieldMetadataItemDocument,
|
||||
"\n query ObjectMetadataItems {\n objects(paging: { first: 1000 }) {\n edges {\n node {\n id\n dataSourceId\n nameSingular\n namePlural\n labelSingular\n labelPlural\n description\n icon\n isCustom\n isRemote\n isActive\n isSystem\n createdAt\n updatedAt\n labelIdentifierFieldMetadataId\n imageIdentifierFieldMetadataId\n shortcut\n isLabelSyncedWithName\n isSearchable\n duplicateCriteria\n indexMetadataList {\n id\n createdAt\n updatedAt\n name\n indexWhereClause\n indexType\n isUnique\n indexFieldMetadataList {\n id\n fieldMetadataId\n createdAt\n updatedAt\n order\n }\n }\n fieldsList {\n id\n type\n name\n label\n description\n icon\n isCustom\n isActive\n isSystem\n isNullable\n isUnique\n createdAt\n updatedAt\n defaultValue\n options\n settings\n isLabelSyncedWithName\n relation {\n type\n sourceObjectMetadata {\n id\n nameSingular\n namePlural\n }\n targetObjectMetadata {\n id\n nameSingular\n namePlural\n }\n sourceFieldMetadata {\n id\n name\n }\n targetFieldMetadata {\n id\n name\n }\n }\n }\n }\n }\n pageInfo {\n hasNextPage\n hasPreviousPage\n startCursor\n endCursor\n }\n }\n }\n": types.ObjectMetadataItemsDocument,
|
||||
"\n fragment ServerlessFunctionFields on ServerlessFunction {\n id\n name\n description\n runtime\n timeoutSeconds\n latestVersion\n latestVersionInputSchema\n publishedVersions\n createdAt\n updatedAt\n }\n": types.ServerlessFunctionFieldsFragmentDoc,
|
||||
"\n \n mutation CreateOneServerlessFunctionItem(\n $input: CreateServerlessFunctionInput!\n ) {\n createOneServerlessFunction(input: $input) {\n ...ServerlessFunctionFields\n }\n }\n": types.CreateOneServerlessFunctionItemDocument,
|
||||
"\n \n mutation DeleteOneServerlessFunction($input: ServerlessFunctionIdInput!) {\n deleteOneServerlessFunction(input: $input) {\n ...ServerlessFunctionFields\n }\n }\n": types.DeleteOneServerlessFunctionDocument,
|
||||
"\n mutation ExecuteOneServerlessFunction(\n $input: ExecuteServerlessFunctionInput!\n ) {\n executeOneServerlessFunction(input: $input) {\n data\n logs\n duration\n status\n error\n }\n }\n": types.ExecuteOneServerlessFunctionDocument,
|
||||
"\n \n mutation PublishOneServerlessFunction(\n $input: PublishServerlessFunctionInput!\n ) {\n publishServerlessFunction(input: $input) {\n ...ServerlessFunctionFields\n }\n }\n": types.PublishOneServerlessFunctionDocument,
|
||||
"\n \n mutation UpdateOneServerlessFunction($input: UpdateServerlessFunctionInput!) {\n updateOneServerlessFunction(input: $input) {\n ...ServerlessFunctionFields\n }\n }\n": types.UpdateOneServerlessFunctionDocument,
|
||||
"\n query FindManyAvailablePackages($input: ServerlessFunctionIdInput!) {\n getAvailablePackages(input: $input)\n }\n": types.FindManyAvailablePackagesDocument,
|
||||
"\n \n query GetManyServerlessFunctions {\n findManyServerlessFunctions {\n ...ServerlessFunctionFields\n }\n }\n": types.GetManyServerlessFunctionsDocument,
|
||||
"\n \n query GetOneServerlessFunction($input: ServerlessFunctionIdInput!) {\n findOneServerlessFunction(input: $input) {\n ...ServerlessFunctionFields\n }\n }\n": types.GetOneServerlessFunctionDocument,
|
||||
"\n query FindOneServerlessFunctionSourceCode(\n $input: GetServerlessFunctionSourceCodeInput!\n ) {\n getServerlessFunctionSourceCode(input: $input)\n }\n": types.FindOneServerlessFunctionSourceCodeDocument,
|
||||
};
|
||||
|
||||
/**
|
||||
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
|
||||
*
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* const query = graphql(`query GetUser($id: ID!) { user(id: $id) { name } }`);
|
||||
* ```
|
||||
*
|
||||
* The query argument is unknown!
|
||||
* Please regenerate the types.
|
||||
*/
|
||||
export function graphql(source: string): unknown;
|
||||
|
||||
/**
|
||||
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
|
||||
*/
|
||||
export function graphql(source: "\n fragment RemoteServerFields on RemoteServer {\n id\n createdAt\n foreignDataWrapperId\n foreignDataWrapperOptions\n foreignDataWrapperType\n userMappingOptions {\n user\n }\n updatedAt\n schema\n label\n }\n"): (typeof documents)["\n fragment RemoteServerFields on RemoteServer {\n id\n createdAt\n foreignDataWrapperId\n foreignDataWrapperOptions\n foreignDataWrapperType\n userMappingOptions {\n user\n }\n updatedAt\n schema\n label\n }\n"];
|
||||
/**
|
||||
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
|
||||
*/
|
||||
export function graphql(source: "\n fragment RemoteTableFields on RemoteTable {\n id\n name\n schema\n status\n schemaPendingUpdates\n }\n"): (typeof documents)["\n fragment RemoteTableFields on RemoteTable {\n id\n name\n schema\n status\n schemaPendingUpdates\n }\n"];
|
||||
/**
|
||||
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
|
||||
*/
|
||||
export function graphql(source: "\n \n mutation createServer($input: CreateRemoteServerInput!) {\n createOneRemoteServer(input: $input) {\n ...RemoteServerFields\n }\n }\n"): (typeof documents)["\n \n mutation createServer($input: CreateRemoteServerInput!) {\n createOneRemoteServer(input: $input) {\n ...RemoteServerFields\n }\n }\n"];
|
||||
/**
|
||||
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
|
||||
*/
|
||||
export function graphql(source: "\n mutation deleteServer($input: RemoteServerIdInput!) {\n deleteOneRemoteServer(input: $input) {\n id\n }\n }\n"): (typeof documents)["\n mutation deleteServer($input: RemoteServerIdInput!) {\n deleteOneRemoteServer(input: $input) {\n id\n }\n }\n"];
|
||||
/**
|
||||
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
|
||||
*/
|
||||
export function graphql(source: "\n \n mutation syncRemoteTable($input: RemoteTableInput!) {\n syncRemoteTable(input: $input) {\n ...RemoteTableFields\n }\n }\n"): (typeof documents)["\n \n mutation syncRemoteTable($input: RemoteTableInput!) {\n syncRemoteTable(input: $input) {\n ...RemoteTableFields\n }\n }\n"];
|
||||
/**
|
||||
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
|
||||
*/
|
||||
export function graphql(source: "\n \n mutation syncRemoteTableSchemaChanges($input: RemoteTableInput!) {\n syncRemoteTableSchemaChanges(input: $input) {\n ...RemoteTableFields\n }\n }\n"): (typeof documents)["\n \n mutation syncRemoteTableSchemaChanges($input: RemoteTableInput!) {\n syncRemoteTableSchemaChanges(input: $input) {\n ...RemoteTableFields\n }\n }\n"];
|
||||
/**
|
||||
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
|
||||
*/
|
||||
export function graphql(source: "\n \n mutation unsyncRemoteTable($input: RemoteTableInput!) {\n unsyncRemoteTable(input: $input) {\n ...RemoteTableFields\n }\n }\n"): (typeof documents)["\n \n mutation unsyncRemoteTable($input: RemoteTableInput!) {\n unsyncRemoteTable(input: $input) {\n ...RemoteTableFields\n }\n }\n"];
|
||||
/**
|
||||
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
|
||||
*/
|
||||
export function graphql(source: "\n \n mutation updateServer($input: UpdateRemoteServerInput!) {\n updateOneRemoteServer(input: $input) {\n ...RemoteServerFields\n }\n }\n"): (typeof documents)["\n \n mutation updateServer($input: UpdateRemoteServerInput!) {\n updateOneRemoteServer(input: $input) {\n ...RemoteServerFields\n }\n }\n"];
|
||||
/**
|
||||
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
|
||||
*/
|
||||
export function graphql(source: "\n \n query GetManyDatabaseConnections($input: RemoteServerTypeInput!) {\n findManyRemoteServersByType(input: $input) {\n ...RemoteServerFields\n }\n }\n"): (typeof documents)["\n \n query GetManyDatabaseConnections($input: RemoteServerTypeInput!) {\n findManyRemoteServersByType(input: $input) {\n ...RemoteServerFields\n }\n }\n"];
|
||||
/**
|
||||
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
|
||||
*/
|
||||
export function graphql(source: "\n \n query GetManyRemoteTables($input: FindManyRemoteTablesInput!) {\n findDistantTablesWithStatus(input: $input) {\n ...RemoteTableFields\n }\n }\n"): (typeof documents)["\n \n query GetManyRemoteTables($input: FindManyRemoteTablesInput!) {\n findDistantTablesWithStatus(input: $input) {\n ...RemoteTableFields\n }\n }\n"];
|
||||
/**
|
||||
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
|
||||
*/
|
||||
export function graphql(source: "\n \n query GetOneDatabaseConnection($input: RemoteServerIdInput!) {\n findOneRemoteServerById(input: $input) {\n ...RemoteServerFields\n }\n }\n"): (typeof documents)["\n \n query GetOneDatabaseConnection($input: RemoteServerIdInput!) {\n findOneRemoteServerById(input: $input) {\n ...RemoteServerFields\n }\n }\n"];
|
||||
/**
|
||||
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
|
||||
*/
|
||||
export function graphql(source: "\n mutation CreateOneObjectMetadataItem($input: CreateOneObjectInput!) {\n createOneObject(input: $input) {\n id\n dataSourceId\n nameSingular\n namePlural\n labelSingular\n labelPlural\n description\n icon\n isCustom\n isActive\n isSearchable\n createdAt\n updatedAt\n labelIdentifierFieldMetadataId\n imageIdentifierFieldMetadataId\n isLabelSyncedWithName\n }\n }\n"): (typeof documents)["\n mutation CreateOneObjectMetadataItem($input: CreateOneObjectInput!) {\n createOneObject(input: $input) {\n id\n dataSourceId\n nameSingular\n namePlural\n labelSingular\n labelPlural\n description\n icon\n isCustom\n isActive\n isSearchable\n createdAt\n updatedAt\n labelIdentifierFieldMetadataId\n imageIdentifierFieldMetadataId\n isLabelSyncedWithName\n }\n }\n"];
|
||||
/**
|
||||
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
|
||||
*/
|
||||
export function graphql(source: "\n mutation CreateOneFieldMetadataItem($input: CreateOneFieldMetadataInput!) {\n createOneField(input: $input) {\n id\n type\n name\n label\n description\n icon\n isCustom\n isActive\n isNullable\n createdAt\n updatedAt\n settings\n defaultValue\n options\n isLabelSyncedWithName\n }\n }\n"): (typeof documents)["\n mutation CreateOneFieldMetadataItem($input: CreateOneFieldMetadataInput!) {\n createOneField(input: $input) {\n id\n type\n name\n label\n description\n icon\n isCustom\n isActive\n isNullable\n createdAt\n updatedAt\n settings\n defaultValue\n options\n isLabelSyncedWithName\n }\n }\n"];
|
||||
/**
|
||||
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
|
||||
*/
|
||||
export function graphql(source: "\n mutation UpdateOneFieldMetadataItem(\n $idToUpdate: UUID!\n $updatePayload: UpdateFieldInput!\n ) {\n updateOneField(input: { id: $idToUpdate, update: $updatePayload }) {\n id\n type\n name\n label\n description\n icon\n isCustom\n isActive\n isNullable\n createdAt\n updatedAt\n settings\n isLabelSyncedWithName\n }\n }\n"): (typeof documents)["\n mutation UpdateOneFieldMetadataItem(\n $idToUpdate: UUID!\n $updatePayload: UpdateFieldInput!\n ) {\n updateOneField(input: { id: $idToUpdate, update: $updatePayload }) {\n id\n type\n name\n label\n description\n icon\n isCustom\n isActive\n isNullable\n createdAt\n updatedAt\n settings\n isLabelSyncedWithName\n }\n }\n"];
|
||||
/**
|
||||
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
|
||||
*/
|
||||
export function graphql(source: "\n mutation UpdateOneObjectMetadataItem(\n $idToUpdate: UUID!\n $updatePayload: UpdateObjectPayload!\n ) {\n updateOneObject(input: { id: $idToUpdate, update: $updatePayload }) {\n id\n dataSourceId\n nameSingular\n namePlural\n labelSingular\n labelPlural\n description\n icon\n isCustom\n isActive\n isSearchable\n createdAt\n updatedAt\n labelIdentifierFieldMetadataId\n imageIdentifierFieldMetadataId\n isLabelSyncedWithName\n }\n }\n"): (typeof documents)["\n mutation UpdateOneObjectMetadataItem(\n $idToUpdate: UUID!\n $updatePayload: UpdateObjectPayload!\n ) {\n updateOneObject(input: { id: $idToUpdate, update: $updatePayload }) {\n id\n dataSourceId\n nameSingular\n namePlural\n labelSingular\n labelPlural\n description\n icon\n isCustom\n isActive\n isSearchable\n createdAt\n updatedAt\n labelIdentifierFieldMetadataId\n imageIdentifierFieldMetadataId\n isLabelSyncedWithName\n }\n }\n"];
|
||||
/**
|
||||
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
|
||||
*/
|
||||
export function graphql(source: "\n mutation DeleteOneObjectMetadataItem($idToDelete: UUID!) {\n deleteOneObject(input: { id: $idToDelete }) {\n id\n dataSourceId\n nameSingular\n namePlural\n labelSingular\n labelPlural\n description\n icon\n isCustom\n isActive\n isSearchable\n createdAt\n updatedAt\n labelIdentifierFieldMetadataId\n imageIdentifierFieldMetadataId\n isLabelSyncedWithName\n }\n }\n"): (typeof documents)["\n mutation DeleteOneObjectMetadataItem($idToDelete: UUID!) {\n deleteOneObject(input: { id: $idToDelete }) {\n id\n dataSourceId\n nameSingular\n namePlural\n labelSingular\n labelPlural\n description\n icon\n isCustom\n isActive\n isSearchable\n createdAt\n updatedAt\n labelIdentifierFieldMetadataId\n imageIdentifierFieldMetadataId\n isLabelSyncedWithName\n }\n }\n"];
|
||||
/**
|
||||
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
|
||||
*/
|
||||
export function graphql(source: "\n mutation DeleteOneFieldMetadataItem($idToDelete: UUID!) {\n deleteOneField(input: { id: $idToDelete }) {\n id\n type\n name\n label\n description\n icon\n isCustom\n isActive\n isNullable\n createdAt\n updatedAt\n settings\n }\n }\n"): (typeof documents)["\n mutation DeleteOneFieldMetadataItem($idToDelete: UUID!) {\n deleteOneField(input: { id: $idToDelete }) {\n id\n type\n name\n label\n description\n icon\n isCustom\n isActive\n isNullable\n createdAt\n updatedAt\n settings\n }\n }\n"];
|
||||
/**
|
||||
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
|
||||
*/
|
||||
export function graphql(source: "\n query ObjectMetadataItems {\n objects(paging: { first: 1000 }) {\n edges {\n node {\n id\n dataSourceId\n nameSingular\n namePlural\n labelSingular\n labelPlural\n description\n icon\n isCustom\n isRemote\n isActive\n isSystem\n createdAt\n updatedAt\n labelIdentifierFieldMetadataId\n imageIdentifierFieldMetadataId\n shortcut\n isLabelSyncedWithName\n isSearchable\n duplicateCriteria\n indexMetadataList {\n id\n createdAt\n updatedAt\n name\n indexWhereClause\n indexType\n isUnique\n indexFieldMetadataList {\n id\n fieldMetadataId\n createdAt\n updatedAt\n order\n }\n }\n fieldsList {\n id\n type\n name\n label\n description\n icon\n isCustom\n isActive\n isSystem\n isNullable\n isUnique\n createdAt\n updatedAt\n defaultValue\n options\n settings\n isLabelSyncedWithName\n relation {\n type\n sourceObjectMetadata {\n id\n nameSingular\n namePlural\n }\n targetObjectMetadata {\n id\n nameSingular\n namePlural\n }\n sourceFieldMetadata {\n id\n name\n }\n targetFieldMetadata {\n id\n name\n }\n }\n }\n }\n }\n pageInfo {\n hasNextPage\n hasPreviousPage\n startCursor\n endCursor\n }\n }\n }\n"): (typeof documents)["\n query ObjectMetadataItems {\n objects(paging: { first: 1000 }) {\n edges {\n node {\n id\n dataSourceId\n nameSingular\n namePlural\n labelSingular\n labelPlural\n description\n icon\n isCustom\n isRemote\n isActive\n isSystem\n createdAt\n updatedAt\n labelIdentifierFieldMetadataId\n imageIdentifierFieldMetadataId\n shortcut\n isLabelSyncedWithName\n isSearchable\n duplicateCriteria\n indexMetadataList {\n id\n createdAt\n updatedAt\n name\n indexWhereClause\n indexType\n isUnique\n indexFieldMetadataList {\n id\n fieldMetadataId\n createdAt\n updatedAt\n order\n }\n }\n fieldsList {\n id\n type\n name\n label\n description\n icon\n isCustom\n isActive\n isSystem\n isNullable\n isUnique\n createdAt\n updatedAt\n defaultValue\n options\n settings\n isLabelSyncedWithName\n relation {\n type\n sourceObjectMetadata {\n id\n nameSingular\n namePlural\n }\n targetObjectMetadata {\n id\n nameSingular\n namePlural\n }\n sourceFieldMetadata {\n id\n name\n }\n targetFieldMetadata {\n id\n name\n }\n }\n }\n }\n }\n pageInfo {\n hasNextPage\n hasPreviousPage\n startCursor\n endCursor\n }\n }\n }\n"];
|
||||
/**
|
||||
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
|
||||
*/
|
||||
export function graphql(source: "\n fragment ServerlessFunctionFields on ServerlessFunction {\n id\n name\n description\n runtime\n timeoutSeconds\n latestVersion\n latestVersionInputSchema\n publishedVersions\n createdAt\n updatedAt\n }\n"): (typeof documents)["\n fragment ServerlessFunctionFields on ServerlessFunction {\n id\n name\n description\n runtime\n timeoutSeconds\n latestVersion\n latestVersionInputSchema\n publishedVersions\n createdAt\n updatedAt\n }\n"];
|
||||
/**
|
||||
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
|
||||
*/
|
||||
export function graphql(source: "\n \n mutation CreateOneServerlessFunctionItem(\n $input: CreateServerlessFunctionInput!\n ) {\n createOneServerlessFunction(input: $input) {\n ...ServerlessFunctionFields\n }\n }\n"): (typeof documents)["\n \n mutation CreateOneServerlessFunctionItem(\n $input: CreateServerlessFunctionInput!\n ) {\n createOneServerlessFunction(input: $input) {\n ...ServerlessFunctionFields\n }\n }\n"];
|
||||
/**
|
||||
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
|
||||
*/
|
||||
export function graphql(source: "\n \n mutation DeleteOneServerlessFunction($input: ServerlessFunctionIdInput!) {\n deleteOneServerlessFunction(input: $input) {\n ...ServerlessFunctionFields\n }\n }\n"): (typeof documents)["\n \n mutation DeleteOneServerlessFunction($input: ServerlessFunctionIdInput!) {\n deleteOneServerlessFunction(input: $input) {\n ...ServerlessFunctionFields\n }\n }\n"];
|
||||
/**
|
||||
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
|
||||
*/
|
||||
export function graphql(source: "\n mutation ExecuteOneServerlessFunction(\n $input: ExecuteServerlessFunctionInput!\n ) {\n executeOneServerlessFunction(input: $input) {\n data\n logs\n duration\n status\n error\n }\n }\n"): (typeof documents)["\n mutation ExecuteOneServerlessFunction(\n $input: ExecuteServerlessFunctionInput!\n ) {\n executeOneServerlessFunction(input: $input) {\n data\n logs\n duration\n status\n error\n }\n }\n"];
|
||||
/**
|
||||
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
|
||||
*/
|
||||
export function graphql(source: "\n \n mutation PublishOneServerlessFunction(\n $input: PublishServerlessFunctionInput!\n ) {\n publishServerlessFunction(input: $input) {\n ...ServerlessFunctionFields\n }\n }\n"): (typeof documents)["\n \n mutation PublishOneServerlessFunction(\n $input: PublishServerlessFunctionInput!\n ) {\n publishServerlessFunction(input: $input) {\n ...ServerlessFunctionFields\n }\n }\n"];
|
||||
/**
|
||||
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
|
||||
*/
|
||||
export function graphql(source: "\n \n mutation UpdateOneServerlessFunction($input: UpdateServerlessFunctionInput!) {\n updateOneServerlessFunction(input: $input) {\n ...ServerlessFunctionFields\n }\n }\n"): (typeof documents)["\n \n mutation UpdateOneServerlessFunction($input: UpdateServerlessFunctionInput!) {\n updateOneServerlessFunction(input: $input) {\n ...ServerlessFunctionFields\n }\n }\n"];
|
||||
/**
|
||||
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
|
||||
*/
|
||||
export function graphql(source: "\n query FindManyAvailablePackages($input: ServerlessFunctionIdInput!) {\n getAvailablePackages(input: $input)\n }\n"): (typeof documents)["\n query FindManyAvailablePackages($input: ServerlessFunctionIdInput!) {\n getAvailablePackages(input: $input)\n }\n"];
|
||||
/**
|
||||
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
|
||||
*/
|
||||
export function graphql(source: "\n \n query GetManyServerlessFunctions {\n findManyServerlessFunctions {\n ...ServerlessFunctionFields\n }\n }\n"): (typeof documents)["\n \n query GetManyServerlessFunctions {\n findManyServerlessFunctions {\n ...ServerlessFunctionFields\n }\n }\n"];
|
||||
/**
|
||||
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
|
||||
*/
|
||||
export function graphql(source: "\n \n query GetOneServerlessFunction($input: ServerlessFunctionIdInput!) {\n findOneServerlessFunction(input: $input) {\n ...ServerlessFunctionFields\n }\n }\n"): (typeof documents)["\n \n query GetOneServerlessFunction($input: ServerlessFunctionIdInput!) {\n findOneServerlessFunction(input: $input) {\n ...ServerlessFunctionFields\n }\n }\n"];
|
||||
/**
|
||||
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
|
||||
*/
|
||||
export function graphql(source: "\n query FindOneServerlessFunctionSourceCode(\n $input: GetServerlessFunctionSourceCodeInput!\n ) {\n getServerlessFunctionSourceCode(input: $input)\n }\n"): (typeof documents)["\n query FindOneServerlessFunctionSourceCode(\n $input: GetServerlessFunctionSourceCodeInput!\n ) {\n getServerlessFunctionSourceCode(input: $input)\n }\n"];
|
||||
|
||||
export function graphql(source: string) {
|
||||
return (documents as any)[source] ?? {};
|
||||
}
|
||||
|
||||
export type DocumentType<TDocumentNode extends DocumentNode<any, any>> = TDocumentNode extends DocumentNode< infer TType, any> ? TType : never;
|
||||
File diff suppressed because one or more lines are too long
@ -1 +0,0 @@
|
||||
export * from "./gql";
|
||||
2704
packages/twenty-front/src/generated/graphql.ts
Normal file
2704
packages/twenty-front/src/generated/graphql.ts
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,3 @@
|
||||
import { useApolloClient } from '@apollo/client';
|
||||
import { useCallback, useMemo } from 'react';
|
||||
import { useRecoilCallback, useRecoilState, useRecoilValue } from 'recoil';
|
||||
import { v4 } from 'uuid';
|
||||
@ -29,6 +28,7 @@ import { getActivityAttachmentPathsToRestore } from '@/activities/utils/getActiv
|
||||
import { commandMenuPageState } from '@/command-menu/states/commandMenuPageState';
|
||||
import { CommandMenuHotkeyScope } from '@/command-menu/types/CommandMenuHotkeyScope';
|
||||
import { CommandMenuPages } from '@/command-menu/types/CommandMenuPages';
|
||||
import { useApolloCoreClient } from '@/object-metadata/hooks/useApolloCoreClient';
|
||||
import { useDeleteManyRecords } from '@/object-record/hooks/useDeleteManyRecords';
|
||||
import { useLazyFetchAllRecords } from '@/object-record/hooks/useLazyFetchAllRecords';
|
||||
import { useRestoreManyRecords } from '@/object-record/hooks/useRestoreManyRecords';
|
||||
@ -59,7 +59,7 @@ export const ActivityRichTextEditor = ({
|
||||
}: ActivityRichTextEditorProps) => {
|
||||
const [activityInStore] = useRecoilState(recordStoreFamilyState(activityId));
|
||||
|
||||
const cache = useApolloClient().cache;
|
||||
const cache = useApolloCoreClient().cache;
|
||||
const activity = activityInStore as Task | Note | null;
|
||||
|
||||
const { objectMetadataItem: objectMetadataItemActivity } =
|
||||
|
||||
@ -5,14 +5,19 @@ import { getFileType } from '@/activities/files/utils/getFileType';
|
||||
import { ActivityTargetableObject } from '@/activities/types/ActivityTargetableEntity';
|
||||
import { getActivityTargetObjectFieldIdName } from '@/activities/utils/getActivityTargetObjectFieldIdName';
|
||||
import { currentWorkspaceMemberState } from '@/auth/states/currentWorkspaceMemberState';
|
||||
import { useApolloCoreClient } from '@/object-metadata/hooks/useApolloCoreClient';
|
||||
import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular';
|
||||
import { useCreateOneRecord } from '@/object-record/hooks/useCreateOneRecord';
|
||||
import { FileFolder, useUploadFileMutation } from '~/generated/graphql';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
import {
|
||||
FileFolder,
|
||||
useUploadFileMutation,
|
||||
} from '~/generated-metadata/graphql';
|
||||
|
||||
export const useUploadAttachmentFile = () => {
|
||||
const currentWorkspaceMember = useRecoilValue(currentWorkspaceMemberState);
|
||||
const [uploadFile] = useUploadFileMutation();
|
||||
const coreClient = useApolloCoreClient();
|
||||
const [uploadFile] = useUploadFileMutation({ client: coreClient });
|
||||
|
||||
const { createOneRecord: createOneAttachment } =
|
||||
useCreateOneRecord<Attachment>({
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import { isNonEmptyArray } from '@sniptt/guards';
|
||||
|
||||
import { ActivityForEditor } from '@/activities/types/ActivityForEditor';
|
||||
import { useApolloCoreClient } from '@/object-metadata/hooks/useApolloCoreClient';
|
||||
import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadataItem';
|
||||
import { useObjectMetadataItems } from '@/object-metadata/hooks/useObjectMetadataItems';
|
||||
import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular';
|
||||
@ -9,7 +10,6 @@ import { modifyRecordFromCache } from '@/object-record/cache/utils/modifyRecordF
|
||||
import { useCreateManyRecords } from '@/object-record/hooks/useCreateManyRecords';
|
||||
import { useCreateOneRecord } from '@/object-record/hooks/useCreateOneRecord';
|
||||
import { recordStoreFamilyState } from '@/object-record/record-store/states/recordStoreFamilyState';
|
||||
import { useApolloClient } from '@apollo/client';
|
||||
|
||||
import { createOneActivityOperationSignatureFactory } from '@/activities/graphql/operation-signatures/factories/createOneActivityOperationSignatureFactory';
|
||||
import { NoteTarget } from '@/activities/types/NoteTarget';
|
||||
@ -55,7 +55,7 @@ export const useCreateActivityInDB = ({
|
||||
objectNameSingular: activityObjectNameSingular,
|
||||
});
|
||||
|
||||
const cache = useApolloClient().cache;
|
||||
const cache = useApolloCoreClient().cache;
|
||||
|
||||
const createActivityInDB = useRecoilCallback(
|
||||
({ set }) =>
|
||||
|
||||
@ -1,11 +1,10 @@
|
||||
import { useApolloClient } from '@apollo/client';
|
||||
|
||||
import { findActivitiesOperationSignatureFactory } from '@/activities/graphql/operation-signatures/factories/findActivitiesOperationSignatureFactory';
|
||||
import { ActivityTargetableObject } from '@/activities/types/ActivityTargetableEntity';
|
||||
import { Note } from '@/activities/types/Note';
|
||||
import { NoteTarget } from '@/activities/types/NoteTarget';
|
||||
import { Task } from '@/activities/types/Task';
|
||||
import { TaskTarget } from '@/activities/types/TaskTarget';
|
||||
import { useApolloCoreClient } from '@/object-metadata/hooks/useApolloCoreClient';
|
||||
import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadataItem';
|
||||
import { useObjectMetadataItems } from '@/object-metadata/hooks/useObjectMetadataItems';
|
||||
import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular';
|
||||
@ -31,7 +30,7 @@ export const usePrepareFindManyActivitiesQuery = ({
|
||||
objectNameSingular: activityObjectNameSingular,
|
||||
});
|
||||
|
||||
const cache = useApolloClient().cache;
|
||||
const cache = useApolloCoreClient().cache;
|
||||
const { objectMetadataItems } = useObjectMetadataItems();
|
||||
const { objectPermissionsByObjectMetadataId } = useObjectPermissions();
|
||||
|
||||
|
||||
@ -4,7 +4,7 @@ import {
|
||||
AnalyticsType,
|
||||
MutationTrackAnalyticsArgs,
|
||||
useTrackAnalyticsMutation,
|
||||
} from '~/generated/graphql';
|
||||
} from '~/generated-metadata/graphql';
|
||||
|
||||
export const ANALYTICS_COOKIE_NAME = 'analyticsCookie';
|
||||
export const getSessionId = (): string => {
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
import { ApolloProvider as ApolloProviderBase } from '@apollo/client';
|
||||
|
||||
import { useApolloFactory } from '@/apollo/hooks/useApolloFactory';
|
||||
import { useRequestFreshCaptchaToken } from '@/captcha/hooks/useRequestFreshCaptchaToken';
|
||||
import { createCaptchaRefreshLink } from '@/apollo/utils/captchaRefreshLink';
|
||||
import { useRequestFreshCaptchaToken } from '@/captcha/hooks/useRequestFreshCaptchaToken';
|
||||
import { REACT_APP_SERVER_BASE_URL } from '~/config';
|
||||
|
||||
export const ApolloProvider = ({ children }: React.PropsWithChildren) => {
|
||||
const { requestFreshCaptchaToken } = useRequestFreshCaptchaToken();
|
||||
@ -10,6 +11,7 @@ export const ApolloProvider = ({ children }: React.PropsWithChildren) => {
|
||||
const captchaRefreshLink = createCaptchaRefreshLink(requestFreshCaptchaToken);
|
||||
|
||||
const apolloClient = useApolloFactory({
|
||||
uri: `${REACT_APP_SERVER_BASE_URL}/metadata`,
|
||||
connectToDevTools: true,
|
||||
extraLinks: [captchaRefreshLink],
|
||||
});
|
||||
|
||||
@ -10,7 +10,7 @@ import { ClientConfigProviderEffect } from '@/client-config/components/ClientCon
|
||||
import { MainContextStoreProvider } from '@/context-store/components/MainContextStoreProvider';
|
||||
import { ErrorMessageEffect } from '@/error-handler/components/ErrorMessageEffect';
|
||||
import { PromiseRejectionEffect } from '@/error-handler/components/PromiseRejectionEffect';
|
||||
import { ApolloMetadataClientProvider } from '@/object-metadata/components/ApolloMetadataClientProvider';
|
||||
import { ApolloCoreProvider } from '@/object-metadata/components/ApolloCoreProvider';
|
||||
import { ObjectMetadataItemsLoadEffect } from '@/object-metadata/components/ObjectMetadataItemsLoadEffect';
|
||||
import { ObjectMetadataItemsProvider } from '@/object-metadata/components/ObjectMetadataItemsProvider';
|
||||
import { PrefetchDataProvider } from '@/prefetch/components/PrefetchDataProvider';
|
||||
@ -44,7 +44,7 @@ export const AppRouterProviders = () => {
|
||||
<ChromeExtensionSidecarProvider>
|
||||
<UserProvider>
|
||||
<AuthProvider>
|
||||
<ApolloMetadataClientProvider>
|
||||
<ApolloCoreProvider>
|
||||
<ObjectMetadataItemsLoadEffect />
|
||||
<ObjectMetadataItemsProvider>
|
||||
<PrefetchDataProvider>
|
||||
@ -67,7 +67,7 @@ export const AppRouterProviders = () => {
|
||||
</PrefetchDataProvider>
|
||||
<PageChangeEffect />
|
||||
</ObjectMetadataItemsProvider>
|
||||
</ApolloMetadataClientProvider>
|
||||
</ApolloCoreProvider>
|
||||
</AuthProvider>
|
||||
</UserProvider>
|
||||
</ChromeExtensionSidecarProvider>
|
||||
|
||||
@ -4,7 +4,7 @@ import {
|
||||
GetLoginTokenFromCredentialsDocument,
|
||||
SignUpDocument,
|
||||
SignUpInWorkspaceDocument,
|
||||
} from '~/generated/graphql';
|
||||
} from '~/generated-metadata/graphql';
|
||||
|
||||
export const queries = {
|
||||
getLoginTokenFromCredentials: GetLoginTokenFromCredentialsDocument,
|
||||
|
||||
@ -23,10 +23,10 @@ import {
|
||||
useGetCurrentUserLazyQuery,
|
||||
useGetLoginTokenFromCredentialsMutation,
|
||||
useGetLoginTokenFromEmailVerificationTokenMutation,
|
||||
useSignUpMutation,
|
||||
useSignInMutation,
|
||||
useSignUpInWorkspaceMutation,
|
||||
} from '~/generated/graphql';
|
||||
useSignUpMutation,
|
||||
} from '~/generated-metadata/graphql';
|
||||
|
||||
import { currentWorkspaceMembersState } from '@/auth/states/currentWorkspaceMembersStates';
|
||||
import { isDeveloperDefaultSignInPrefilledState } from '@/client-config/states/isDeveloperDefaultSignInPrefilledState';
|
||||
@ -41,6 +41,8 @@ import { getTimeFormatFromWorkspaceTimeFormat } from '@/localization/utils/getTi
|
||||
import { currentUserState } from '../states/currentUserState';
|
||||
import { tokenPairState } from '../states/tokenPairState';
|
||||
|
||||
import { useSignUpInNewWorkspace } from '@/auth/sign-in-up/hooks/useSignUpInNewWorkspace';
|
||||
import { availableWorkspacesState } from '@/auth/states/availableWorkspacesState';
|
||||
import { currentUserWorkspaceState } from '@/auth/states/currentUserWorkspaceState';
|
||||
import { isCurrentUserLoadedState } from '@/auth/states/isCurrentUserLoadedState';
|
||||
import {
|
||||
@ -49,6 +51,11 @@ import {
|
||||
} from '@/auth/states/signInUpStepState';
|
||||
import { workspacePublicDataState } from '@/auth/states/workspacePublicDataState';
|
||||
import { BillingCheckoutSession } from '@/auth/types/billingCheckoutSession.type';
|
||||
import {
|
||||
countAvailableWorkspaces,
|
||||
getFirstAvailableWorkspaces,
|
||||
} from '@/auth/utils/availableWorkspacesUtils';
|
||||
import { useRequestFreshCaptchaToken } from '@/captcha/hooks/useRequestFreshCaptchaToken';
|
||||
import { apiConfigState } from '@/client-config/states/apiConfigState';
|
||||
import { captchaState } from '@/client-config/states/captchaState';
|
||||
import { isEmailVerificationRequiredState } from '@/client-config/states/isEmailVerificationRequiredState';
|
||||
@ -70,13 +77,6 @@ import { iconsState } from 'twenty-ui/display';
|
||||
import { cookieStorage } from '~/utils/cookie-storage';
|
||||
import { getWorkspaceUrl } from '~/utils/getWorkspaceUrl';
|
||||
import { dynamicActivate } from '~/utils/i18n/dynamicActivate';
|
||||
import { availableWorkspacesState } from '@/auth/states/availableWorkspacesState';
|
||||
import { useSignUpInNewWorkspace } from '@/auth/sign-in-up/hooks/useSignUpInNewWorkspace';
|
||||
import {
|
||||
countAvailableWorkspaces,
|
||||
getFirstAvailableWorkspaces,
|
||||
} from '@/auth/utils/availableWorkspacesUtils';
|
||||
import { useRequestFreshCaptchaToken } from '@/captcha/hooks/useRequestFreshCaptchaToken';
|
||||
|
||||
export const useAuth = () => {
|
||||
const setTokenPair = useSetRecoilState(tokenPairState);
|
||||
|
||||
@ -7,14 +7,14 @@ import {
|
||||
} from '@apollo/client';
|
||||
|
||||
import { loggerLink } from '@/apollo/utils/loggerLink';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
import {
|
||||
AuthTokenPair,
|
||||
RenewTokenDocument,
|
||||
RenewTokenMutation,
|
||||
RenewTokenMutationVariables,
|
||||
} from '~/generated/graphql';
|
||||
} from '~/generated-metadata/graphql';
|
||||
import { isUndefinedOrNull } from '~/utils/isUndefinedOrNull';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
const logger = loggerLink(() => 'Twenty-Refresh');
|
||||
|
||||
|
||||
@ -4,19 +4,19 @@ import { act, renderHook } from '@testing-library/react';
|
||||
import { RecoilRoot } from 'recoil';
|
||||
|
||||
import { useHandleResetPassword } from '@/auth/sign-in-up/hooks/useHandleResetPassword';
|
||||
import { workspacePublicDataState } from '@/auth/states/workspacePublicDataState';
|
||||
import { SnackBarVariant } from '@/ui/feedback/snack-bar-manager/components/SnackBar';
|
||||
import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar';
|
||||
import { SOURCE_LOCALE } from 'twenty-shared/translations';
|
||||
import {
|
||||
PublicWorkspaceDataOutput,
|
||||
useEmailPasswordResetLinkMutation,
|
||||
} from '~/generated/graphql';
|
||||
} from '~/generated-metadata/graphql';
|
||||
import { dynamicActivate } from '~/utils/i18n/dynamicActivate';
|
||||
import { workspacePublicDataState } from '@/auth/states/workspacePublicDataState';
|
||||
import { SOURCE_LOCALE } from 'twenty-shared/translations';
|
||||
|
||||
// Mocks
|
||||
jest.mock('@/ui/feedback/snack-bar-manager/hooks/useSnackBar');
|
||||
jest.mock('~/generated/graphql');
|
||||
jest.mock('~/generated-metadata/graphql');
|
||||
|
||||
dynamicActivate(SOURCE_LOCALE);
|
||||
|
||||
|
||||
@ -4,7 +4,7 @@ import { useOrigin } from '@/domain-manager/hooks/useOrigin';
|
||||
import { SnackBarVariant } from '@/ui/feedback/snack-bar-manager/components/SnackBar';
|
||||
import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar';
|
||||
import { t } from '@lingui/core/macro';
|
||||
import { useResendEmailVerificationTokenMutation } from '~/generated/graphql';
|
||||
import { useResendEmailVerificationTokenMutation } from '~/generated-metadata/graphql';
|
||||
|
||||
export const useHandleResendEmailVerificationToken = () => {
|
||||
const { enqueueSnackBar } = useSnackBar();
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
import { useCallback } from 'react';
|
||||
|
||||
import { currentUserState } from '@/auth/states/currentUserState';
|
||||
import { workspacePublicDataState } from '@/auth/states/workspacePublicDataState';
|
||||
import { SnackBarVariant } from '@/ui/feedback/snack-bar-manager/components/SnackBar';
|
||||
import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar';
|
||||
import { useLingui } from '@lingui/react/macro';
|
||||
import { useEmailPasswordResetLinkMutation } from '~/generated/graphql';
|
||||
import { workspacePublicDataState } from '@/auth/states/workspacePublicDataState';
|
||||
import { useRecoilValue } from 'recoil';
|
||||
import { currentUserState } from '@/auth/states/currentUserState';
|
||||
import { useEmailPasswordResetLinkMutation } from '~/generated-metadata/graphql';
|
||||
|
||||
export const useHandleResetPassword = () => {
|
||||
const { enqueueSnackBar } = useSnackBar();
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
import { getWorkspaceUrl } from '~/utils/getWorkspaceUrl';
|
||||
import { AppPath } from '@/types/AppPath';
|
||||
import { useSignUpInNewWorkspaceMutation } from '~/generated/graphql';
|
||||
import { useRedirectToWorkspaceDomain } from '@/domain-manager/hooks/useRedirectToWorkspaceDomain';
|
||||
import { AppPath } from '@/types/AppPath';
|
||||
import { SnackBarVariant } from '@/ui/feedback/snack-bar-manager/components/SnackBar';
|
||||
import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar';
|
||||
import { useSignUpInNewWorkspaceMutation } from '~/generated-metadata/graphql';
|
||||
import { getWorkspaceUrl } from '~/utils/getWorkspaceUrl';
|
||||
|
||||
export const useSignUpInNewWorkspace = () => {
|
||||
const { redirectToWorkspaceDomain } = useRedirectToWorkspaceDomain();
|
||||
|
||||
@ -9,7 +9,7 @@ import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar';
|
||||
|
||||
import { AppPath } from '@/types/AppPath';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
import { useGetWorkspaceFromInviteHashQuery } from '~/generated/graphql';
|
||||
import { useGetWorkspaceFromInviteHashQuery } from '~/generated-metadata/graphql';
|
||||
import { useNavigateApp } from '~/hooks/useNavigateApp';
|
||||
|
||||
export const useWorkspaceFromInviteHash = () => {
|
||||
|
||||
@ -1,17 +1,27 @@
|
||||
import { SubscriptionInfoContainer } from '@/billing/components/SubscriptionInfoContainer';
|
||||
import { SubscriptionInfoRowContainer } from '@/billing/components/SubscriptionInfoRowContainer';
|
||||
|
||||
import { currentWorkspaceState } from '@/auth/states/currentWorkspaceState';
|
||||
import { formatMonthlyPrices } from '@/billing/utils/formatMonthlyPrices';
|
||||
import { SnackBarVariant } from '@/ui/feedback/snack-bar-manager/components/SnackBar';
|
||||
import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar';
|
||||
import { ConfirmationModal } from '@/ui/layout/modal/components/ConfirmationModal';
|
||||
import { useModal } from '@/ui/layout/modal/hooks/useModal';
|
||||
import { useSubscriptionStatus } from '@/workspace/hooks/useSubscriptionStatus';
|
||||
import styled from '@emotion/styled';
|
||||
import { useLingui } from '@lingui/react/macro';
|
||||
import { useRecoilState } from 'recoil';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
import { Tag } from 'twenty-ui/components';
|
||||
import {
|
||||
H2Title,
|
||||
IconArrowUp,
|
||||
IconCalendarEvent,
|
||||
IconTag,
|
||||
IconUsers,
|
||||
IconArrowUp,
|
||||
} from 'twenty-ui/display';
|
||||
import { Button } from 'twenty-ui/input';
|
||||
import { Section } from 'twenty-ui/layout';
|
||||
import styled from '@emotion/styled';
|
||||
import { useLingui } from '@lingui/react/macro';
|
||||
import {
|
||||
BillingPlanKey,
|
||||
BillingPlanOutput,
|
||||
@ -21,17 +31,7 @@ import {
|
||||
useBillingBaseProductPricesQuery,
|
||||
useSwitchSubscriptionToEnterprisePlanMutation,
|
||||
useSwitchSubscriptionToYearlyIntervalMutation,
|
||||
} from '~/generated/graphql';
|
||||
import { useRecoilState } from 'recoil';
|
||||
import { currentWorkspaceState } from '@/auth/states/currentWorkspaceState';
|
||||
import { Tag } from 'twenty-ui/components';
|
||||
import { useModal } from '@/ui/layout/modal/hooks/useModal';
|
||||
import { useSubscriptionStatus } from '@/workspace/hooks/useSubscriptionStatus';
|
||||
import { ConfirmationModal } from '@/ui/layout/modal/components/ConfirmationModal';
|
||||
import { formatMonthlyPrices } from '@/billing/utils/formatMonthlyPrices';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
import { SnackBarVariant } from '@/ui/feedback/snack-bar-manager/components/SnackBar';
|
||||
import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar';
|
||||
} from '~/generated-metadata/graphql';
|
||||
|
||||
const SWITCH_BILLING_INTERVAL_MODAL_ID = 'switch-billing-interval-modal';
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@ import { t } from '@lingui/core/macro';
|
||||
import { useState } from 'react';
|
||||
import { useRecoilState } from 'recoil';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
import { useEndSubscriptionTrialPeriodMutation } from '~/generated/graphql';
|
||||
import { useEndSubscriptionTrialPeriodMutation } from '~/generated-metadata/graphql';
|
||||
|
||||
export const useEndSubscriptionTrialPeriod = () => {
|
||||
const { enqueueSnackBar } = useSnackBar();
|
||||
|
||||
@ -3,7 +3,7 @@ import {
|
||||
BillingProductKey,
|
||||
SubscriptionStatus,
|
||||
useGetMeteredProductsUsageQuery,
|
||||
} from '~/generated/graphql';
|
||||
} from '~/generated-metadata/graphql';
|
||||
|
||||
export const useGetWorkflowNodeExecutionUsage = () => {
|
||||
const subscriptionStatus = useSubscriptionStatus();
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import { useRedirect } from '@/domain-manager/hooks/useRedirect';
|
||||
import { SettingsPath } from '@/types/SettingsPath';
|
||||
import { SnackBarVariant } from '@/ui/feedback/snack-bar-manager/components/SnackBar';
|
||||
import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar';
|
||||
@ -5,10 +6,9 @@ import { useState } from 'react';
|
||||
import {
|
||||
BillingPlanKey,
|
||||
SubscriptionInterval,
|
||||
useCheckoutSessionMutation,
|
||||
} from '~/generated-metadata/graphql';
|
||||
import { useCheckoutSessionMutation } from '~/generated/graphql';
|
||||
import { getSettingsPath } from '~/utils/navigation/getSettingsPath';
|
||||
import { useRedirect } from '@/domain-manager/hooks/useRedirect';
|
||||
|
||||
export const useHandleCheckoutSession = ({
|
||||
recurringInterval,
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
import { commandMenuNavigationMorphItemByPageState } from '@/command-menu/states/commandMenuNavigationMorphItemsState';
|
||||
import { commandMenuNavigationRecordsState } from '@/command-menu/states/commandMenuNavigationRecordsState';
|
||||
import { commandMenuNavigationStackState } from '@/command-menu/states/commandMenuNavigationStackState';
|
||||
import { useApolloCoreClient } from '@/object-metadata/hooks/useApolloCoreClient';
|
||||
import { objectMetadataItemsState } from '@/object-metadata/states/objectMetadataItemsState';
|
||||
import { getRecordFromCache } from '@/object-record/cache/utils/getRecordFromCache';
|
||||
import { useObjectPermissions } from '@/object-record/hooks/useObjectPermissions';
|
||||
import { useApolloClient } from '@apollo/client';
|
||||
import { useEffect } from 'react';
|
||||
import { useRecoilValue, useSetRecoilState } from 'recoil';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
@ -25,7 +25,7 @@ export const CommandMenuContextChipRecordSetterEffect = () => {
|
||||
commandMenuNavigationStackState,
|
||||
);
|
||||
|
||||
const apolloClient = useApolloClient();
|
||||
const apolloCoreClient = useApolloCoreClient();
|
||||
|
||||
useEffect(() => {
|
||||
if (commandMenuNavigationStack.length > 1) {
|
||||
@ -45,7 +45,7 @@ export const CommandMenuContextChipRecordSetterEffect = () => {
|
||||
|
||||
const record = getRecordFromCache({
|
||||
recordId: morphItem.recordId,
|
||||
cache: apolloClient.cache,
|
||||
cache: apolloCoreClient.cache,
|
||||
objectMetadataItems,
|
||||
objectMetadataItem,
|
||||
objectPermissionsByObjectMetadataId,
|
||||
@ -65,7 +65,7 @@ export const CommandMenuContextChipRecordSetterEffect = () => {
|
||||
setCommandMenuNavigationRecords(records);
|
||||
}
|
||||
}, [
|
||||
apolloClient.cache,
|
||||
apolloCoreClient.cache,
|
||||
commandMenuNavigationMorphItemByPage,
|
||||
commandMenuNavigationStack,
|
||||
commandMenuNavigationStack.length,
|
||||
|
||||
@ -7,6 +7,7 @@ import { useOpenRecordInCommandMenu } from '@/command-menu/hooks/useOpenRecordIn
|
||||
import { commandMenuSearchState } from '@/command-menu/states/commandMenuSearchState';
|
||||
import { useObjectMetadataItems } from '@/object-metadata/hooks/useObjectMetadataItems';
|
||||
import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular';
|
||||
import { useApolloCoreClient } from '@/object-metadata/hooks/useApolloCoreClient';
|
||||
import { useObjectPermissions } from '@/object-record/hooks/useObjectPermissions';
|
||||
import { AppPath } from '@/types/AppPath';
|
||||
import { t } from '@lingui/core/macro';
|
||||
@ -19,6 +20,7 @@ import { useSearchQuery } from '~/generated/graphql';
|
||||
|
||||
export const useCommandMenuSearchRecords = () => {
|
||||
const commandMenuSearch = useRecoilValue(commandMenuSearchState);
|
||||
const coreClient = useApolloCoreClient();
|
||||
|
||||
const [deferredCommandMenuSearch] = useDebounce(commandMenuSearch, 300);
|
||||
const { objectPermissionsByObjectMetadataId } = useObjectPermissions();
|
||||
@ -36,6 +38,7 @@ export const useCommandMenuSearchRecords = () => {
|
||||
}, [objectMetadataItems, objectPermissionsByObjectMetadataId]);
|
||||
|
||||
const { data: searchData, loading } = useSearchQuery({
|
||||
client: coreClient,
|
||||
variables: {
|
||||
searchInput: deferredCommandMenuSearch ?? '',
|
||||
limit: MAX_SEARCH_RESULTS,
|
||||
|
||||
@ -2,7 +2,7 @@ import { useMutation } from '@apollo/client';
|
||||
|
||||
import { CREATE_ONE_DATABASE_CONNECTION } from '@/databases/graphql/mutations/createOneDatabaseConnection';
|
||||
import { GET_MANY_DATABASE_CONNECTIONS } from '@/databases/graphql/queries/findManyDatabaseConnections';
|
||||
import { useApolloMetadataClient } from '@/object-metadata/hooks/useApolloMetadataClient';
|
||||
import { useApolloCoreClient } from '@/object-metadata/hooks/useApolloCoreClient';
|
||||
import {
|
||||
CreateRemoteServerInput,
|
||||
CreateServerMutation,
|
||||
@ -11,7 +11,7 @@ import {
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
export const useCreateOneDatabaseConnection = () => {
|
||||
const apolloMetadataClient = useApolloMetadataClient();
|
||||
const apolloMetadataClient = useApolloCoreClient();
|
||||
|
||||
const [mutate] = useMutation<
|
||||
CreateServerMutation,
|
||||
|
||||
@ -3,7 +3,7 @@ import { getOperationName } from '@apollo/client/utilities';
|
||||
|
||||
import { DELETE_ONE_DATABASE_CONNECTION } from '@/databases/graphql/mutations/deleteOneDatabaseConnection';
|
||||
import { GET_MANY_DATABASE_CONNECTIONS } from '@/databases/graphql/queries/findManyDatabaseConnections';
|
||||
import { useApolloMetadataClient } from '@/object-metadata/hooks/useApolloMetadataClient';
|
||||
import { useApolloCoreClient } from '@/object-metadata/hooks/useApolloCoreClient';
|
||||
import {
|
||||
DeleteServerMutation,
|
||||
DeleteServerMutationVariables,
|
||||
@ -11,7 +11,7 @@ import {
|
||||
} from '~/generated-metadata/graphql';
|
||||
|
||||
export const useDeleteOneDatabaseConnection = () => {
|
||||
const apolloMetadataClient = useApolloMetadataClient();
|
||||
const apolloMetadataClient = useApolloCoreClient();
|
||||
|
||||
const [mutate] = useMutation<
|
||||
DeleteServerMutation,
|
||||
|
||||
@ -2,7 +2,7 @@ import { useQuery, WatchQueryFetchPolicy } from '@apollo/client';
|
||||
|
||||
import { GET_ONE_DATABASE_CONNECTION } from '@/databases/graphql/queries/findOneDatabaseConnection';
|
||||
import { getForeignDataWrapperType } from '@/databases/utils/getForeignDataWrapperType';
|
||||
import { useApolloMetadataClient } from '@/object-metadata/hooks/useApolloMetadataClient';
|
||||
import { useApolloCoreClient } from '@/object-metadata/hooks/useApolloCoreClient';
|
||||
import {
|
||||
GetOneDatabaseConnectionQuery,
|
||||
GetOneDatabaseConnectionQueryVariables,
|
||||
@ -21,7 +21,7 @@ export const useGetDatabaseConnection = ({
|
||||
skip,
|
||||
fetchPolicy,
|
||||
}: UseGetDatabaseConnectionParams) => {
|
||||
const apolloMetadataClient = useApolloMetadataClient();
|
||||
const apolloMetadataClient = useApolloCoreClient();
|
||||
const foreignDataWrapperType = getForeignDataWrapperType(databaseKey);
|
||||
|
||||
const fetchPolicyOption = fetchPolicy ? { fetchPolicy: fetchPolicy } : {};
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { useQuery, WatchQueryFetchPolicy } from '@apollo/client';
|
||||
|
||||
import { GET_MANY_REMOTE_TABLES } from '@/databases/graphql/queries/findManyRemoteTables';
|
||||
import { useApolloMetadataClient } from '@/object-metadata/hooks/useApolloMetadataClient';
|
||||
import { useApolloCoreClient } from '@/object-metadata/hooks/useApolloCoreClient';
|
||||
import {
|
||||
GetManyRemoteTablesQuery,
|
||||
GetManyRemoteTablesQueryVariables,
|
||||
@ -20,7 +20,7 @@ export const useGetDatabaseConnectionTables = ({
|
||||
shouldFetchPendingSchemaUpdates,
|
||||
fetchPolicy,
|
||||
}: UseGetDatabaseConnectionTablesParams) => {
|
||||
const apolloMetadataClient = useApolloMetadataClient();
|
||||
const apolloMetadataClient = useApolloCoreClient();
|
||||
|
||||
const fetchPolicyOption = fetchPolicy ? { fetchPolicy: fetchPolicy } : {};
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@ import { useQuery } from '@apollo/client';
|
||||
|
||||
import { GET_MANY_DATABASE_CONNECTIONS } from '@/databases/graphql/queries/findManyDatabaseConnections';
|
||||
import { getForeignDataWrapperType } from '@/databases/utils/getForeignDataWrapperType';
|
||||
import { useApolloMetadataClient } from '@/object-metadata/hooks/useApolloMetadataClient';
|
||||
import { useApolloCoreClient } from '@/object-metadata/hooks/useApolloCoreClient';
|
||||
import {
|
||||
GetManyDatabaseConnectionsQuery,
|
||||
GetManyDatabaseConnectionsQueryVariables,
|
||||
@ -17,7 +17,7 @@ export const useGetDatabaseConnections = ({
|
||||
databaseKey,
|
||||
skip,
|
||||
}: UseGetDatabaseConnectionsParams) => {
|
||||
const apolloMetadataClient = useApolloMetadataClient();
|
||||
const apolloMetadataClient = useApolloCoreClient();
|
||||
const foreignDataWrapperType = getForeignDataWrapperType(databaseKey);
|
||||
|
||||
const { data } = useQuery<
|
||||
|
||||
@ -3,7 +3,7 @@ import { useCallback } from 'react';
|
||||
|
||||
import { SYNC_REMOTE_TABLE } from '@/databases/graphql/mutations/syncRemoteTable';
|
||||
import { modifyRemoteTableFromCache } from '@/databases/utils/modifyRemoteTableFromCache';
|
||||
import { useApolloMetadataClient } from '@/object-metadata/hooks/useApolloMetadataClient';
|
||||
import { useApolloCoreClient } from '@/object-metadata/hooks/useApolloCoreClient';
|
||||
import { useFindManyObjectMetadataItems } from '@/object-metadata/hooks/useFindManyObjectMetadataItems';
|
||||
import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular';
|
||||
import { useFindManyRecordsQuery } from '@/object-record/hooks/useFindManyRecordsQuery';
|
||||
@ -15,7 +15,7 @@ import {
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
export const useSyncRemoteTable = () => {
|
||||
const apolloMetadataClient = useApolloMetadataClient();
|
||||
const apolloMetadataClient = useApolloCoreClient();
|
||||
const apolloClient = useApolloClient();
|
||||
|
||||
const { refetch: refetchObjectMetadataItems } =
|
||||
|
||||
@ -3,7 +3,7 @@ import { useCallback } from 'react';
|
||||
|
||||
import { SYNC_REMOTE_TABLE_SCHEMA_CHANGES } from '@/databases/graphql/mutations/syncRemoteTableSchemaChanges';
|
||||
import { modifyRemoteTableFromCache } from '@/databases/utils/modifyRemoteTableFromCache';
|
||||
import { useApolloMetadataClient } from '@/object-metadata/hooks/useApolloMetadataClient';
|
||||
import { useApolloCoreClient } from '@/object-metadata/hooks/useApolloCoreClient';
|
||||
import { useFindManyObjectMetadataItems } from '@/object-metadata/hooks/useFindManyObjectMetadataItems';
|
||||
import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular';
|
||||
import { useFindManyRecordsQuery } from '@/object-record/hooks/useFindManyRecordsQuery';
|
||||
@ -15,7 +15,7 @@ import {
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
export const useSyncRemoteTableSchemaChanges = () => {
|
||||
const apolloMetadataClient = useApolloMetadataClient();
|
||||
const apolloMetadataClient = useApolloCoreClient();
|
||||
const apolloClient = useApolloClient();
|
||||
|
||||
const { refetch: refetchObjectMetadataItems } =
|
||||
|
||||
@ -3,7 +3,7 @@ import { useCallback } from 'react';
|
||||
|
||||
import { UNSYNC_REMOTE_TABLE } from '@/databases/graphql/mutations/unsyncRemoteTable';
|
||||
import { modifyRemoteTableFromCache } from '@/databases/utils/modifyRemoteTableFromCache';
|
||||
import { useApolloMetadataClient } from '@/object-metadata/hooks/useApolloMetadataClient';
|
||||
import { useApolloCoreClient } from '@/object-metadata/hooks/useApolloCoreClient';
|
||||
import { useFindManyObjectMetadataItems } from '@/object-metadata/hooks/useFindManyObjectMetadataItems';
|
||||
import {
|
||||
RemoteTableInput,
|
||||
@ -13,7 +13,7 @@ import {
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
export const useUnsyncRemoteTable = () => {
|
||||
const apolloMetadataClient = useApolloMetadataClient();
|
||||
const apolloMetadataClient = useApolloCoreClient();
|
||||
const { refetch: refetchObjectMetadataItems } =
|
||||
useFindManyObjectMetadataItems();
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { useMutation } from '@apollo/client';
|
||||
|
||||
import { UPDATE_ONE_DATABASE_CONNECTION } from '@/databases/graphql/mutations/updateOneDatabaseConnection';
|
||||
import { useApolloMetadataClient } from '@/object-metadata/hooks/useApolloMetadataClient';
|
||||
import { useApolloCoreClient } from '@/object-metadata/hooks/useApolloCoreClient';
|
||||
import {
|
||||
UpdateRemoteServerInput,
|
||||
UpdateServerMutation,
|
||||
@ -9,7 +9,7 @@ import {
|
||||
} from '~/generated-metadata/graphql';
|
||||
|
||||
export const useUpdateOneDatabaseConnection = () => {
|
||||
const apolloMetadataClient = useApolloMetadataClient();
|
||||
const apolloMetadataClient = useApolloCoreClient();
|
||||
|
||||
const [mutate] = useMutation<
|
||||
UpdateServerMutation,
|
||||
|
||||
@ -7,7 +7,7 @@ import { useRedirectToDefaultDomain } from '@/domain-manager/hooks/useRedirectTo
|
||||
import { workspaceAuthProvidersState } from '@/workspace/states/workspaceAuthProvidersState';
|
||||
import { useRecoilValue, useSetRecoilState } from 'recoil';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
import { useGetPublicWorkspaceDataByDomainQuery } from '~/generated/graphql';
|
||||
import { useGetPublicWorkspaceDataByDomainQuery } from '~/generated-metadata/graphql';
|
||||
|
||||
export const useGetPublicWorkspaceDataByDomain = () => {
|
||||
const { isDefaultDomain } = useIsCurrentLocationOnDefaultDomain();
|
||||
|
||||
@ -7,7 +7,7 @@ import { isDefined } from 'twenty-shared/utils';
|
||||
import {
|
||||
SettingPermissionType,
|
||||
useBillingPortalSessionQuery,
|
||||
} from '~/generated/graphql';
|
||||
} from '~/generated-metadata/graphql';
|
||||
import { getSettingsPath } from '~/utils/navigation/getSettingsPath';
|
||||
|
||||
export const InformationBannerBillingSubscriptionPaused = () => {
|
||||
|
||||
@ -7,7 +7,7 @@ import { isDefined } from 'twenty-shared/utils';
|
||||
import {
|
||||
SettingPermissionType,
|
||||
useBillingPortalSessionQuery,
|
||||
} from '~/generated/graphql';
|
||||
} from '~/generated-metadata/graphql';
|
||||
import { getSettingsPath } from '~/utils/navigation/getSettingsPath';
|
||||
|
||||
export const InformationBannerFailPaymentInfo = () => {
|
||||
|
||||
@ -0,0 +1,21 @@
|
||||
import { useApolloFactory } from '@/apollo/hooks/useApolloFactory';
|
||||
import { REACT_APP_SERVER_BASE_URL } from '~/config';
|
||||
|
||||
import { ApolloCoreClientContext } from '../contexts/ApolloCoreClientContext';
|
||||
|
||||
export const ApolloCoreProvider = ({
|
||||
children,
|
||||
}: {
|
||||
children: React.ReactNode;
|
||||
}) => {
|
||||
const apolloCoreClient = useApolloFactory({
|
||||
uri: `${REACT_APP_SERVER_BASE_URL}/graphql`,
|
||||
connectToDevTools: true, // @Felix I am not sure if this is correct, should be false?
|
||||
});
|
||||
|
||||
return (
|
||||
<ApolloCoreClientContext.Provider value={apolloCoreClient}>
|
||||
{children}
|
||||
</ApolloCoreClientContext.Provider>
|
||||
);
|
||||
};
|
||||
@ -1,21 +0,0 @@
|
||||
import { useApolloFactory } from '@/apollo/hooks/useApolloFactory';
|
||||
import { REACT_APP_SERVER_BASE_URL } from '~/config';
|
||||
|
||||
import { ApolloMetadataClientContext } from '../contexts/ApolloClientMetadataContext';
|
||||
|
||||
export const ApolloMetadataClientProvider = ({
|
||||
children,
|
||||
}: {
|
||||
children: React.ReactNode;
|
||||
}) => {
|
||||
const apolloMetadataClient = useApolloFactory({
|
||||
uri: `${REACT_APP_SERVER_BASE_URL}/metadata`,
|
||||
connectToDevTools: false,
|
||||
});
|
||||
|
||||
return (
|
||||
<ApolloMetadataClientContext.Provider value={apolloMetadataClient}>
|
||||
{children}
|
||||
</ApolloMetadataClientContext.Provider>
|
||||
);
|
||||
};
|
||||
@ -1,5 +1,5 @@
|
||||
import { createContext } from 'react';
|
||||
import { ApolloClient, NormalizedCacheObject } from '@apollo/client';
|
||||
|
||||
export const ApolloMetadataClientContext =
|
||||
export const ApolloCoreClientContext =
|
||||
createContext<ApolloClient<NormalizedCacheObject> | null>(null);
|
||||
@ -0,0 +1,16 @@
|
||||
import { ReactNode } from 'react';
|
||||
|
||||
import { ApolloCoreClientContext } from '@/object-metadata/contexts/ApolloCoreClientContext';
|
||||
import { mockedApolloCoreClient } from '~/testing/mockedApolloCoreClient';
|
||||
|
||||
export const ApolloCoreClientMockedProvider = ({
|
||||
children,
|
||||
}: {
|
||||
children: ReactNode;
|
||||
}) => {
|
||||
return (
|
||||
<ApolloCoreClientContext.Provider value={mockedApolloCoreClient}>
|
||||
{mockedApolloCoreClient ? children : ''}
|
||||
</ApolloCoreClientContext.Provider>
|
||||
);
|
||||
};
|
||||
@ -1,16 +0,0 @@
|
||||
import { ReactNode } from 'react';
|
||||
|
||||
import { ApolloMetadataClientContext } from '@/object-metadata/contexts/ApolloClientMetadataContext';
|
||||
import { mockedMetadataApolloClient } from '~/testing/mockedMetadataApolloClient';
|
||||
|
||||
export const ApolloMetadataClientMockedProvider = ({
|
||||
children,
|
||||
}: {
|
||||
children: ReactNode;
|
||||
}) => {
|
||||
return (
|
||||
<ApolloMetadataClientContext.Provider value={mockedMetadataApolloClient}>
|
||||
{mockedMetadataApolloClient ? children : ''}
|
||||
</ApolloMetadataClientContext.Provider>
|
||||
);
|
||||
};
|
||||
@ -3,7 +3,7 @@ import { act } from 'react';
|
||||
|
||||
import { useFieldMetadataItem } from '@/object-metadata/hooks/useFieldMetadataItem';
|
||||
import { FieldMetadataItem } from '@/object-metadata/types/FieldMetadataItem';
|
||||
import { FieldMetadataType, RelationType } from '~/generated/graphql';
|
||||
import { FieldMetadataType, RelationType } from '~/generated-metadata/graphql';
|
||||
|
||||
import { getJestMetadataAndApolloMocksWrapper } from '~/testing/jest/getJestMetadataAndApolloMocksWrapper';
|
||||
import {
|
||||
|
||||
@ -0,0 +1,18 @@
|
||||
import { ApolloCoreClientContext } from '@/object-metadata/contexts/ApolloCoreClientContext';
|
||||
import { useApolloClient } from '@apollo/client';
|
||||
import { useContext } from 'react';
|
||||
|
||||
export const useApolloCoreClient = () => {
|
||||
const apolloCoreClient = useContext(ApolloCoreClientContext);
|
||||
const apolloClient = useApolloClient();
|
||||
|
||||
if (process.env.NODE_ENV === 'test') {
|
||||
return apolloClient;
|
||||
}
|
||||
|
||||
if (!apolloCoreClient) {
|
||||
throw new Error('ApolloCoreClient not found');
|
||||
}
|
||||
|
||||
return apolloCoreClient;
|
||||
};
|
||||
@ -1,18 +0,0 @@
|
||||
import { ApolloMetadataClientContext } from '@/object-metadata/contexts/ApolloClientMetadataContext';
|
||||
import { useApolloClient } from '@apollo/client';
|
||||
import { useContext } from 'react';
|
||||
|
||||
export const useApolloMetadataClient = () => {
|
||||
const apolloMetadataClient = useContext(ApolloMetadataClientContext);
|
||||
const apolloClient = useApolloClient();
|
||||
|
||||
if (process.env.NODE_ENV === 'test') {
|
||||
return apolloClient;
|
||||
}
|
||||
|
||||
if (!apolloMetadataClient) {
|
||||
throw new Error('ApolloMetadataClient not found');
|
||||
}
|
||||
|
||||
return apolloMetadataClient;
|
||||
};
|
||||
@ -9,19 +9,15 @@ import {
|
||||
import { CREATE_ONE_FIELD_METADATA_ITEM } from '../graphql/mutations';
|
||||
|
||||
import { useRefreshObjectMetadataItems } from '@/object-metadata/hooks/useRefreshObjectMetadataItem';
|
||||
import { useApolloMetadataClient } from './useApolloMetadataClient';
|
||||
|
||||
export const useCreateOneFieldMetadataItem = () => {
|
||||
const apolloMetadataClient = useApolloMetadataClient();
|
||||
const { refreshObjectMetadataItems } =
|
||||
useRefreshObjectMetadataItems('network-only');
|
||||
|
||||
const [mutate] = useMutation<
|
||||
CreateOneFieldMetadataItemMutation,
|
||||
CreateOneFieldMetadataItemMutationVariables
|
||||
>(CREATE_ONE_FIELD_METADATA_ITEM, {
|
||||
client: apolloMetadataClient,
|
||||
});
|
||||
>(CREATE_ONE_FIELD_METADATA_ITEM);
|
||||
|
||||
const createOneFieldMetadataItem = async (input: CreateFieldInput) => {
|
||||
const result = await mutate({
|
||||
|
||||
@ -10,21 +10,17 @@ import { CREATE_ONE_OBJECT_METADATA_ITEM } from '../graphql/mutations';
|
||||
|
||||
import { useRefreshObjectMetadataItems } from '@/object-metadata/hooks/useRefreshObjectMetadataItem';
|
||||
import { useRefreshCachedViews } from '@/views/hooks/useRefreshViews';
|
||||
import { useApolloMetadataClient } from './useApolloMetadataClient';
|
||||
|
||||
export const useCreateOneObjectMetadataItem = () => {
|
||||
const { refreshCachedViews } = useRefreshCachedViews();
|
||||
|
||||
const apolloMetadataClient = useApolloMetadataClient();
|
||||
const { refreshObjectMetadataItems } =
|
||||
useRefreshObjectMetadataItems('network-only');
|
||||
|
||||
const [mutate] = useMutation<
|
||||
CreateOneObjectMetadataItemMutation,
|
||||
CreateOneObjectMetadataItemMutationVariables
|
||||
>(CREATE_ONE_OBJECT_METADATA_ITEM, {
|
||||
client: apolloMetadataClient,
|
||||
});
|
||||
>(CREATE_ONE_OBJECT_METADATA_ITEM);
|
||||
|
||||
const createOneObjectMetadataItem = async (input: CreateObjectInput) => {
|
||||
const createdObjectMetadata = await mutate({
|
||||
|
||||
@ -10,17 +10,12 @@ import { recordIndexKanbanAggregateOperationState } from '@/object-record/record
|
||||
import { AggregateOperations } from '@/object-record/record-table/constants/AggregateOperations';
|
||||
import { useRecoilState } from 'recoil';
|
||||
import { DELETE_ONE_FIELD_METADATA_ITEM } from '../graphql/mutations';
|
||||
import { useApolloMetadataClient } from './useApolloMetadataClient';
|
||||
|
||||
export const useDeleteOneFieldMetadataItem = () => {
|
||||
const apolloMetadataClient = useApolloMetadataClient();
|
||||
|
||||
const [mutate] = useMutation<
|
||||
DeleteOneFieldMetadataItemMutation,
|
||||
DeleteOneFieldMetadataItemMutationVariables
|
||||
>(DELETE_ONE_FIELD_METADATA_ITEM, {
|
||||
client: apolloMetadataClient,
|
||||
});
|
||||
>(DELETE_ONE_FIELD_METADATA_ITEM);
|
||||
|
||||
const { refreshObjectMetadataItems } =
|
||||
useRefreshObjectMetadataItems('network-only');
|
||||
|
||||
@ -8,17 +8,12 @@ import {
|
||||
import { DELETE_ONE_OBJECT_METADATA_ITEM } from '../graphql/mutations';
|
||||
|
||||
import { useRefreshObjectMetadataItems } from '@/object-metadata/hooks/useRefreshObjectMetadataItem';
|
||||
import { useApolloMetadataClient } from './useApolloMetadataClient';
|
||||
|
||||
export const useDeleteOneObjectMetadataItem = () => {
|
||||
const apolloMetadataClient = useApolloMetadataClient();
|
||||
|
||||
const [mutate] = useMutation<
|
||||
DeleteOneObjectMetadataItemMutation,
|
||||
DeleteOneObjectMetadataItemMutationVariables
|
||||
>(DELETE_ONE_OBJECT_METADATA_ITEM, {
|
||||
client: apolloMetadataClient,
|
||||
});
|
||||
>(DELETE_ONE_OBJECT_METADATA_ITEM);
|
||||
|
||||
const { refreshObjectMetadataItems } =
|
||||
useRefreshObjectMetadataItems('network-only');
|
||||
|
||||
@ -12,23 +12,18 @@ import { logError } from '~/utils/logError';
|
||||
import { FIND_MANY_OBJECT_METADATA_ITEMS } from '../graphql/queries';
|
||||
import { mapPaginatedObjectMetadataItemsToObjectMetadataItems } from '../utils/mapPaginatedObjectMetadataItemsToObjectMetadataItems';
|
||||
|
||||
import { useApolloMetadataClient } from './useApolloMetadataClient';
|
||||
|
||||
export const useFindManyObjectMetadataItems = ({
|
||||
skip,
|
||||
}: {
|
||||
skip?: boolean;
|
||||
} = {}) => {
|
||||
const apolloMetadataClient = useApolloMetadataClient();
|
||||
|
||||
const { enqueueSnackBar } = useSnackBar();
|
||||
|
||||
const { data, loading, error, refetch } = useQuery<
|
||||
ObjectMetadataItemsQuery,
|
||||
ObjectMetadataItemsQueryVariables
|
||||
>(FIND_MANY_OBJECT_METADATA_ITEMS, {
|
||||
client: apolloMetadataClient ?? undefined,
|
||||
skip: skip || !apolloMetadataClient,
|
||||
skip,
|
||||
onError: (error) => {
|
||||
logError('useFindManyObjectMetadataItems error : ' + error);
|
||||
enqueueSnackBar(`${error.message}`, {
|
||||
|
||||
@ -1,10 +1,9 @@
|
||||
import { FIND_MANY_OBJECT_METADATA_ITEMS } from '@/object-metadata/graphql/queries';
|
||||
import { useApolloMetadataClient } from '@/object-metadata/hooks/useApolloMetadataClient';
|
||||
import { isAppWaitingForFreshObjectMetadataState } from '@/object-metadata/states/isAppWaitingForFreshObjectMetadataState';
|
||||
import { objectMetadataItemsState } from '@/object-metadata/states/objectMetadataItemsState';
|
||||
import { ObjectMetadataItem } from '@/object-metadata/types/ObjectMetadataItem';
|
||||
import { mapPaginatedObjectMetadataItemsToObjectMetadataItems } from '@/object-metadata/utils/mapPaginatedObjectMetadataItemsToObjectMetadataItems';
|
||||
import { FetchPolicy } from '@apollo/client';
|
||||
import { FetchPolicy, useApolloClient } from '@apollo/client';
|
||||
import { useRecoilCallback } from 'recoil';
|
||||
import { ObjectMetadataItemsQuery } from '~/generated-metadata/graphql';
|
||||
import { isDeeplyEqual } from '~/utils/isDeeplyEqual';
|
||||
@ -12,7 +11,7 @@ import { isDeeplyEqual } from '~/utils/isDeeplyEqual';
|
||||
export const useRefreshObjectMetadataItems = (
|
||||
fetchPolicy: FetchPolicy = 'network-only',
|
||||
) => {
|
||||
const client = useApolloMetadataClient();
|
||||
const client = useApolloClient();
|
||||
|
||||
const refreshObjectMetadataItems = async () => {
|
||||
const result = await client.query<ObjectMetadataItemsQuery>({
|
||||
|
||||
@ -18,10 +18,8 @@ import { getRecordsFromRecordConnection } from '@/object-record/cache/utils/getR
|
||||
import { RecordGqlConnection } from '@/object-record/graphql/types/RecordGqlConnection';
|
||||
import { useSetRecordGroups } from '@/object-record/record-group/hooks/useSetRecordGroups';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
import { useApolloMetadataClient } from './useApolloMetadataClient';
|
||||
|
||||
export const useUpdateOneFieldMetadataItem = () => {
|
||||
const apolloMetadataClient = useApolloMetadataClient();
|
||||
const apolloClient = useApolloClient();
|
||||
const { refreshObjectMetadataItems } =
|
||||
useRefreshObjectMetadataItems('network-only');
|
||||
@ -48,9 +46,7 @@ export const useUpdateOneFieldMetadataItem = () => {
|
||||
const [mutate] = useMutation<
|
||||
UpdateOneFieldMetadataItemMutation,
|
||||
UpdateOneFieldMetadataItemMutationVariables
|
||||
>(UPDATE_ONE_FIELD_METADATA_ITEM, {
|
||||
client: apolloMetadataClient ?? undefined,
|
||||
});
|
||||
>(UPDATE_ONE_FIELD_METADATA_ITEM);
|
||||
|
||||
const updateOneFieldMetadataItem = async ({
|
||||
objectMetadataId,
|
||||
|
||||
@ -9,18 +9,13 @@ import {
|
||||
import { UPDATE_ONE_OBJECT_METADATA_ITEM } from '../graphql/mutations';
|
||||
|
||||
import { useRefreshObjectMetadataItems } from '@/object-metadata/hooks/useRefreshObjectMetadataItem';
|
||||
import { useApolloMetadataClient } from './useApolloMetadataClient';
|
||||
|
||||
// TODO: Slice the Apollo store synchronously in the update function instead of subscribing, so we can use update after read in the same function call
|
||||
export const useUpdateOneObjectMetadataItem = () => {
|
||||
const apolloClientMetadata = useApolloMetadataClient();
|
||||
|
||||
const [mutate, { loading }] = useMutation<
|
||||
UpdateOneObjectMetadataItemMutation,
|
||||
UpdateOneObjectMetadataItemMutationVariables
|
||||
>(UPDATE_ONE_OBJECT_METADATA_ITEM, {
|
||||
client: apolloClientMetadata ?? undefined,
|
||||
});
|
||||
>(UPDATE_ONE_OBJECT_METADATA_ITEM);
|
||||
|
||||
const { refreshObjectMetadataItems } =
|
||||
useRefreshObjectMetadataItems('network-only');
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { useApolloClient } from '@apollo/client';
|
||||
import gql from 'graphql-tag';
|
||||
import { useRecoilValue } from 'recoil';
|
||||
|
||||
import { useApolloCoreClient } from '@/object-metadata/hooks/useApolloCoreClient';
|
||||
import { objectMetadataItemsState } from '@/object-metadata/states/objectMetadataItemsState';
|
||||
import { ObjectMetadataItem } from '@/object-metadata/types/ObjectMetadataItem';
|
||||
import { mapObjectMetadataToGraphQLQuery } from '@/object-metadata/utils/mapObjectMetadataToGraphQLQuery';
|
||||
@ -24,7 +24,7 @@ export const useCreateOneRecordInCache = <T extends ObjectRecord>({
|
||||
const objectMetadataItems = useRecoilValue(objectMetadataItemsState);
|
||||
const { objectPermissionsByObjectMetadataId } = useObjectPermissions();
|
||||
|
||||
const apolloClient = useApolloClient();
|
||||
const apolloCoreClient = useApolloCoreClient();
|
||||
|
||||
return (record: ObjectRecord) => {
|
||||
const prefilledRecord = prefillRecord({
|
||||
@ -60,7 +60,7 @@ export const useCreateOneRecordInCache = <T extends ObjectRecord>({
|
||||
...recordToCreateWithNestedConnections,
|
||||
};
|
||||
|
||||
apolloClient.writeFragment({
|
||||
apolloCoreClient.writeFragment({
|
||||
id: `${capitalize(objectMetadataItem.nameSingular)}:${record.id}`,
|
||||
fragment,
|
||||
data: cachedObjectRecord,
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
import { useApolloClient } from '@apollo/client';
|
||||
|
||||
import { useApolloCoreClient } from '@/object-metadata/hooks/useApolloCoreClient';
|
||||
import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadataItem';
|
||||
import { useObjectMetadataItems } from '@/object-metadata/hooks/useObjectMetadataItems';
|
||||
import { deleteRecordFromCache } from '@/object-record/cache/utils/deleteRecordFromCache';
|
||||
@ -10,7 +9,7 @@ export const useDeleteRecordFromCache = ({
|
||||
}: {
|
||||
objectNameSingular: string;
|
||||
}) => {
|
||||
const apolloClient = useApolloClient();
|
||||
const apolloCoreClient = useApolloCoreClient();
|
||||
|
||||
const { objectMetadataItem } = useObjectMetadataItem({
|
||||
objectNameSingular,
|
||||
@ -23,7 +22,7 @@ export const useDeleteRecordFromCache = ({
|
||||
objectMetadataItem,
|
||||
objectMetadataItems,
|
||||
recordToDestroy,
|
||||
cache: apolloClient.cache,
|
||||
cache: apolloCoreClient.cache,
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { useApolloClient } from '@apollo/client';
|
||||
import { useCallback } from 'react';
|
||||
import { useRecoilValue } from 'recoil';
|
||||
|
||||
import { useApolloCoreClient } from '@/object-metadata/hooks/useApolloCoreClient';
|
||||
import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadataItem';
|
||||
import { objectMetadataItemsState } from '@/object-metadata/states/objectMetadataItemsState';
|
||||
import { getRecordFromCache } from '@/object-record/cache/utils/getRecordFromCache';
|
||||
@ -27,12 +27,12 @@ export const useGetRecordFromCache = ({
|
||||
const objectMetadataItems = useRecoilValue(objectMetadataItemsState);
|
||||
const { objectPermissionsByObjectMetadataId } = useObjectPermissions();
|
||||
|
||||
const apolloClient = useApolloClient();
|
||||
const apolloCoreClient = useApolloCoreClient();
|
||||
|
||||
return useCallback(
|
||||
<T extends ObjectRecord = ObjectRecord>(
|
||||
recordId: string,
|
||||
cache = apolloClient.cache,
|
||||
cache = apolloCoreClient.cache,
|
||||
) => {
|
||||
return getRecordFromCache<T>({
|
||||
cache,
|
||||
@ -44,7 +44,7 @@ export const useGetRecordFromCache = ({
|
||||
});
|
||||
},
|
||||
[
|
||||
apolloClient.cache,
|
||||
apolloCoreClient.cache,
|
||||
objectMetadataItems,
|
||||
objectMetadataItem,
|
||||
appliedRecordGqlFields,
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
import { useApolloClient } from '@apollo/client';
|
||||
|
||||
import { useApolloCoreClient } from '@/object-metadata/hooks/useApolloCoreClient';
|
||||
import { useObjectMetadataItems } from '@/object-metadata/hooks/useObjectMetadataItems';
|
||||
import { ObjectMetadataItem } from '@/object-metadata/types/ObjectMetadataItem';
|
||||
import { getRecordsFromRecordConnection } from '@/object-record/cache/utils/getRecordsFromRecordConnection';
|
||||
@ -15,7 +14,7 @@ export const useReadFindManyRecordsQueryInCache = ({
|
||||
}: {
|
||||
objectMetadataItem: ObjectMetadataItem;
|
||||
}) => {
|
||||
const apolloClient = useApolloClient();
|
||||
const apolloCoreClient = useApolloCoreClient();
|
||||
|
||||
const { objectMetadataItems } = useObjectMetadataItems();
|
||||
|
||||
@ -38,7 +37,7 @@ export const useReadFindManyRecordsQueryInCache = ({
|
||||
});
|
||||
|
||||
const existingRecordsQueryResult =
|
||||
apolloClient.readQuery<RecordGqlOperationFindManyResult>({
|
||||
apolloCoreClient.readQuery<RecordGqlOperationFindManyResult>({
|
||||
query: findManyRecordsQueryForCacheRead,
|
||||
variables: queryVariables,
|
||||
});
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { useApolloClient } from '@apollo/client';
|
||||
import { useRecoilValue } from 'recoil';
|
||||
|
||||
import { useApolloCoreClient } from '@/object-metadata/hooks/useApolloCoreClient';
|
||||
import { objectMetadataItemsState } from '@/object-metadata/states/objectMetadataItemsState';
|
||||
import { ObjectMetadataItem } from '@/object-metadata/types/ObjectMetadataItem';
|
||||
import { getRecordConnectionFromRecords } from '@/object-record/cache/utils/getRecordConnectionFromRecords';
|
||||
@ -14,7 +14,7 @@ export const useUpsertFindManyRecordsQueryInCache = ({
|
||||
}: {
|
||||
objectMetadataItem: ObjectMetadataItem;
|
||||
}) => {
|
||||
const apolloClient = useApolloClient();
|
||||
const apolloCoreClient = useApolloCoreClient();
|
||||
|
||||
const objectMetadataItems = useRecoilValue(objectMetadataItemsState);
|
||||
const { objectPermissionsByObjectMetadataId } = useObjectPermissions();
|
||||
@ -48,7 +48,7 @@ export const useUpsertFindManyRecordsQueryInCache = ({
|
||||
computeReferences,
|
||||
});
|
||||
|
||||
apolloClient.writeQuery({
|
||||
apolloCoreClient.writeQuery({
|
||||
query: findManyRecordsQueryForCacheOverwrite,
|
||||
variables: queryVariables,
|
||||
data: {
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
import { useApolloClient } from '@apollo/client';
|
||||
|
||||
import { useApolloCoreClient } from '@/object-metadata/hooks/useApolloCoreClient';
|
||||
import { ObjectMetadataItem } from '@/object-metadata/types/ObjectMetadataItem';
|
||||
import { useFindOneRecordQuery } from '@/object-record/hooks/useFindOneRecordQuery';
|
||||
import { ObjectRecord } from '@/object-record/types/ObjectRecord';
|
||||
@ -13,7 +12,7 @@ export const useUpsertFindOneRecordQueryInCache = ({
|
||||
recordGqlFields: Record<string, any>;
|
||||
withSoftDeleted?: boolean;
|
||||
}) => {
|
||||
const apolloClient = useApolloClient();
|
||||
const apolloCoreClient = useApolloCoreClient();
|
||||
|
||||
const { findOneRecordQuery } = useFindOneRecordQuery({
|
||||
objectNameSingular: objectMetadataItem.nameSingular,
|
||||
@ -30,7 +29,7 @@ export const useUpsertFindOneRecordQueryInCache = ({
|
||||
objectRecordId: string;
|
||||
objectRecordToOverwrite: T;
|
||||
}) => {
|
||||
apolloClient.writeQuery({
|
||||
apolloCoreClient.writeQuery({
|
||||
query: findOneRecordQuery,
|
||||
variables: { objectRecordId },
|
||||
data: {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { ObjectMetadataItem } from '@/object-metadata/types/ObjectMetadataItem';
|
||||
import { FieldMetadataType } from '~/generated/graphql';
|
||||
import { FieldMetadataType } from '~/generated-metadata/graphql';
|
||||
|
||||
type GenerateDepthOneWithoutRelationsRecordGqlFields = {
|
||||
objectMetadataItem: ObjectMetadataItem;
|
||||
|
||||
@ -5,7 +5,8 @@ import { useAggregateRecordsQuery } from '@/object-record/hooks/useAggregateReco
|
||||
import { AggregateOperations } from '@/object-record/record-table/constants/AggregateOperations';
|
||||
import { generateAggregateQuery } from '@/object-record/utils/generateAggregateQuery';
|
||||
import { renderHook } from '@testing-library/react';
|
||||
import { FieldMetadataType } from '~/generated/graphql';
|
||||
import { FieldMetadataType } from '~/generated-metadata/graphql';
|
||||
import { getJestMetadataAndApolloMocksWrapper } from '~/testing/jest/getJestMetadataAndApolloMocksWrapper';
|
||||
|
||||
jest.mock('@/object-metadata/hooks/useObjectMetadataItem');
|
||||
jest.mock('@/object-record/utils/generateAggregateQuery');
|
||||
@ -50,6 +51,10 @@ const mockObjectMetadataItem: ObjectMetadataItem = {
|
||||
isSystem: false,
|
||||
};
|
||||
|
||||
const Wrapper = getJestMetadataAndApolloMocksWrapper({
|
||||
apolloMocks: [],
|
||||
});
|
||||
|
||||
describe('useAggregateRecordsQuery', () => {
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
@ -67,13 +72,15 @@ describe('useAggregateRecordsQuery', () => {
|
||||
});
|
||||
|
||||
it('should handle simple count operation', () => {
|
||||
const { result } = renderHook(() =>
|
||||
useAggregateRecordsQuery({
|
||||
objectNameSingular: 'company',
|
||||
recordGqlFieldsAggregate: {
|
||||
name: [AggregateOperations.COUNT],
|
||||
},
|
||||
}),
|
||||
const { result } = renderHook(
|
||||
() =>
|
||||
useAggregateRecordsQuery({
|
||||
objectNameSingular: 'company',
|
||||
recordGqlFieldsAggregate: {
|
||||
name: [AggregateOperations.COUNT],
|
||||
},
|
||||
}),
|
||||
{ wrapper: Wrapper },
|
||||
);
|
||||
|
||||
expect(result.current.gqlFieldToFieldMap).toEqual({
|
||||
@ -88,13 +95,15 @@ describe('useAggregateRecordsQuery', () => {
|
||||
});
|
||||
|
||||
it('should handle field aggregation', () => {
|
||||
const { result } = renderHook(() =>
|
||||
useAggregateRecordsQuery({
|
||||
objectNameSingular: 'company',
|
||||
recordGqlFieldsAggregate: {
|
||||
amount: [AggregateOperations.SUM],
|
||||
},
|
||||
}),
|
||||
const { result } = renderHook(
|
||||
() =>
|
||||
useAggregateRecordsQuery({
|
||||
objectNameSingular: 'company',
|
||||
recordGqlFieldsAggregate: {
|
||||
amount: [AggregateOperations.SUM],
|
||||
},
|
||||
}),
|
||||
{ wrapper: Wrapper },
|
||||
);
|
||||
|
||||
expect(result.current.gqlFieldToFieldMap).toEqual({
|
||||
@ -111,26 +120,30 @@ describe('useAggregateRecordsQuery', () => {
|
||||
|
||||
it('should throw error for invalid aggregation operation', () => {
|
||||
expect(() =>
|
||||
renderHook(() =>
|
||||
useAggregateRecordsQuery({
|
||||
objectNameSingular: 'company',
|
||||
recordGqlFieldsAggregate: {
|
||||
name: [AggregateOperations.SUM],
|
||||
},
|
||||
}),
|
||||
renderHook(
|
||||
() =>
|
||||
useAggregateRecordsQuery({
|
||||
objectNameSingular: 'company',
|
||||
recordGqlFieldsAggregate: {
|
||||
name: [AggregateOperations.SUM],
|
||||
},
|
||||
}),
|
||||
{ wrapper: Wrapper },
|
||||
),
|
||||
).toThrow();
|
||||
});
|
||||
|
||||
it('should handle multiple aggregations', () => {
|
||||
const { result } = renderHook(() =>
|
||||
useAggregateRecordsQuery({
|
||||
objectNameSingular: 'company',
|
||||
recordGqlFieldsAggregate: {
|
||||
amount: [AggregateOperations.SUM],
|
||||
name: [AggregateOperations.COUNT],
|
||||
},
|
||||
}),
|
||||
const { result } = renderHook(
|
||||
() =>
|
||||
useAggregateRecordsQuery({
|
||||
objectNameSingular: 'company',
|
||||
recordGqlFieldsAggregate: {
|
||||
amount: [AggregateOperations.SUM],
|
||||
name: [AggregateOperations.COUNT],
|
||||
},
|
||||
}),
|
||||
{ wrapper: Wrapper },
|
||||
);
|
||||
|
||||
expect(result.current.gqlFieldToFieldMap).toHaveProperty('sumAmount');
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
import { useApolloCoreClient } from '@/object-metadata/hooks/useApolloCoreClient';
|
||||
import { useRefetchAggregateQueries } from '@/object-record/hooks/useRefetchAggregateQueries';
|
||||
import { getAggregateQueryName } from '@/object-record/utils/getAggregateQueryName';
|
||||
import { useApolloClient } from '@apollo/client';
|
||||
import { renderHook } from '@testing-library/react';
|
||||
|
||||
jest.mock('@apollo/client', () => ({
|
||||
useApolloClient: jest.fn(),
|
||||
jest.mock('@/object-metadata/hooks/useApolloCoreClient', () => ({
|
||||
useApolloCoreClient: jest.fn(),
|
||||
}));
|
||||
|
||||
describe('useRefetchAggregateQueries', () => {
|
||||
@ -15,7 +15,7 @@ describe('useRefetchAggregateQueries', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
(useApolloClient as jest.Mock).mockReturnValue(mockApolloClient);
|
||||
(useApolloCoreClient as jest.Mock).mockReturnValue(mockApolloClient);
|
||||
});
|
||||
|
||||
it('should refetch queries', async () => {
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
import { useQuery } from '@apollo/client';
|
||||
|
||||
import { useApolloCoreClient } from '@/object-metadata/hooks/useApolloCoreClient';
|
||||
import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadataItem';
|
||||
import { RecordGqlFieldsAggregate } from '@/object-record/graphql/types/RecordGqlFieldsAggregate';
|
||||
import { RecordGqlOperationFilter } from '@/object-record/graphql/types/RecordGqlOperationFilter';
|
||||
@ -31,6 +32,8 @@ export const useAggregateRecords = <T extends AggregateRecordsData>({
|
||||
objectNameSingular,
|
||||
});
|
||||
|
||||
const apolloCoreClient = useApolloCoreClient();
|
||||
|
||||
const { aggregateQuery, gqlFieldToFieldMap } = useAggregateRecordsQuery({
|
||||
objectNameSingular,
|
||||
recordGqlFieldsAggregate,
|
||||
@ -49,6 +52,7 @@ export const useAggregateRecords = <T extends AggregateRecordsData>({
|
||||
variables: {
|
||||
filter,
|
||||
},
|
||||
client: apolloCoreClient,
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import { useApolloCoreClient } from '@/object-metadata/hooks/useApolloCoreClient';
|
||||
import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadataItem';
|
||||
import { RecordGqlFields } from '@/object-record/graphql/types/RecordGqlFields';
|
||||
import { RecordGqlFieldsAggregate } from '@/object-record/graphql/types/RecordGqlFieldsAggregate';
|
||||
@ -25,6 +26,7 @@ export const useAggregateRecordsQuery = ({
|
||||
objectNameSingular,
|
||||
});
|
||||
|
||||
const apolloCoreClient = useApolloCoreClient();
|
||||
const availableAggregations = useMemo(
|
||||
() => getAvailableAggregationsFromObjectFields(objectMetadataItem.fields),
|
||||
[objectMetadataItem.fields],
|
||||
@ -49,6 +51,9 @@ export const useAggregateRecordsQuery = ({
|
||||
recordGqlFields[fieldToQuery] = true;
|
||||
});
|
||||
},
|
||||
{
|
||||
client: apolloCoreClient,
|
||||
},
|
||||
);
|
||||
|
||||
const aggregateQuery = generateAggregateQuery({
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
import { useApolloClient } from '@apollo/client';
|
||||
|
||||
import { CustomError } from '@/error-handler/CustomError';
|
||||
import { useApolloCoreClient } from '@/object-metadata/hooks/useApolloCoreClient';
|
||||
import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadataItem';
|
||||
import { useObjectMetadataItems } from '@/object-metadata/hooks/useObjectMetadataItems';
|
||||
import { useGetRecordFromCache } from '@/object-record/cache/hooks/useGetRecordFromCache';
|
||||
@ -20,7 +19,7 @@ export const useAttachRelatedRecordFromRecord = ({
|
||||
recordObjectNameSingular,
|
||||
fieldNameOnRecordObject,
|
||||
}: useAttachRelatedRecordFromRecordProps) => {
|
||||
const apolloClient = useApolloClient();
|
||||
const apolloCoreClient = useApolloCoreClient();
|
||||
|
||||
const { objectMetadataItem } = useObjectMetadataItem({
|
||||
objectNameSingular: recordObjectNameSingular,
|
||||
@ -98,7 +97,7 @@ export const useAttachRelatedRecordFromRecord = ({
|
||||
updateRecordFromCache({
|
||||
objectMetadataItems,
|
||||
objectMetadataItem: relatedObjectMetadataItem,
|
||||
cache: apolloClient.cache,
|
||||
cache: apolloCoreClient.cache,
|
||||
record: {
|
||||
...cachedRelatedRecord,
|
||||
[fieldOnRelatedObject]: previousRecord,
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
import { useApolloClient } from '@apollo/client';
|
||||
import { v4 } from 'uuid';
|
||||
|
||||
import { triggerCreateRecordsOptimisticEffect } from '@/apollo/optimistic-effect/utils/triggerCreateRecordsOptimisticEffect';
|
||||
import { triggerDestroyRecordsOptimisticEffect } from '@/apollo/optimistic-effect/utils/triggerDestroyRecordsOptimisticEffect';
|
||||
import { currentWorkspaceMemberState } from '@/auth/states/currentWorkspaceMemberState';
|
||||
import { useApolloCoreClient } from '@/object-metadata/hooks/useApolloCoreClient';
|
||||
import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadataItem';
|
||||
import { useObjectMetadataItems } from '@/object-metadata/hooks/useObjectMetadataItems';
|
||||
import { hasObjectMetadataItemFieldCreatedBy } from '@/object-metadata/utils/hasObjectMetadataItemFieldCreatedBy';
|
||||
@ -49,7 +49,7 @@ export const useCreateManyRecords = <
|
||||
shouldMatchRootQueryFilter,
|
||||
shouldRefetchAggregateQueries = true,
|
||||
}: useCreateManyRecordsProps) => {
|
||||
const apolloClient = useApolloClient();
|
||||
const apolloCoreClient = useApolloCoreClient();
|
||||
|
||||
const { objectMetadataItem } = useObjectMetadataItem({
|
||||
objectNameSingular,
|
||||
@ -120,7 +120,7 @@ export const useCreateManyRecords = <
|
||||
if (shouldDoOptimisticEffect) {
|
||||
const optimisticRecordInput = {
|
||||
...computeOptimisticRecordFromInput({
|
||||
cache: apolloClient.cache,
|
||||
cache: apolloCoreClient.cache,
|
||||
objectMetadataItem,
|
||||
objectMetadataItems,
|
||||
currentWorkspaceMember: currentWorkspaceMember,
|
||||
@ -158,7 +158,7 @@ export const useCreateManyRecords = <
|
||||
.filter(isDefined);
|
||||
|
||||
triggerCreateRecordsOptimisticEffect({
|
||||
cache: apolloClient.cache,
|
||||
cache: apolloCoreClient.cache,
|
||||
objectMetadataItem,
|
||||
recordsToCreate: recordNodeCreatedInCache,
|
||||
objectMetadataItems,
|
||||
@ -171,7 +171,7 @@ export const useCreateManyRecords = <
|
||||
objectMetadataItem.namePlural,
|
||||
);
|
||||
|
||||
const createdObjects = await apolloClient
|
||||
const createdObjects = await apolloCoreClient
|
||||
.mutate({
|
||||
mutation: createManyRecordsMutation,
|
||||
variables: {
|
||||
@ -204,13 +204,13 @@ export const useCreateManyRecords = <
|
||||
deleteRecordFromCache({
|
||||
objectMetadataItems,
|
||||
objectMetadataItem,
|
||||
cache: apolloClient.cache,
|
||||
cache: apolloCoreClient.cache,
|
||||
recordToDestroy,
|
||||
});
|
||||
});
|
||||
|
||||
triggerDestroyRecordsOptimisticEffect({
|
||||
cache: apolloClient.cache,
|
||||
cache: apolloCoreClient.cache,
|
||||
objectMetadataItem,
|
||||
recordsToDestroy: recordsCreatedInCache,
|
||||
objectMetadataItems,
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
import { useApolloClient } from '@apollo/client';
|
||||
import { useState } from 'react';
|
||||
import { v4 } from 'uuid';
|
||||
|
||||
import { triggerCreateRecordsOptimisticEffect } from '@/apollo/optimistic-effect/utils/triggerCreateRecordsOptimisticEffect';
|
||||
import { triggerDestroyRecordsOptimisticEffect } from '@/apollo/optimistic-effect/utils/triggerDestroyRecordsOptimisticEffect';
|
||||
import { currentWorkspaceMemberState } from '@/auth/states/currentWorkspaceMemberState';
|
||||
import { useApolloCoreClient } from '@/object-metadata/hooks/useApolloCoreClient';
|
||||
import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadataItem';
|
||||
import { useObjectMetadataItems } from '@/object-metadata/hooks/useObjectMetadataItems';
|
||||
import { useCreateOneRecordInCache } from '@/object-record/cache/hooks/useCreateOneRecordInCache';
|
||||
@ -39,7 +39,7 @@ export const useCreateOneRecord = <
|
||||
skipPostOptimisticEffect = false,
|
||||
shouldMatchRootQueryFilter,
|
||||
}: useCreateOneRecordProps) => {
|
||||
const apolloClient = useApolloClient();
|
||||
const apolloCoreClient = useApolloCoreClient();
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
const { objectMetadataItem } = useObjectMetadataItem({
|
||||
@ -83,7 +83,7 @@ export const useCreateOneRecord = <
|
||||
};
|
||||
|
||||
const optimisticRecordInput = computeOptimisticRecordFromInput({
|
||||
cache: apolloClient.cache,
|
||||
cache: apolloCoreClient.cache,
|
||||
currentWorkspaceMember: currentWorkspaceMember,
|
||||
objectMetadataItem,
|
||||
objectMetadataItems,
|
||||
@ -111,7 +111,7 @@ export const useCreateOneRecord = <
|
||||
|
||||
if (skipPostOptimisticEffect === false && optimisticRecordNode !== null) {
|
||||
triggerCreateRecordsOptimisticEffect({
|
||||
cache: apolloClient.cache,
|
||||
cache: apolloCoreClient.cache,
|
||||
objectMetadataItem,
|
||||
recordsToCreate: [optimisticRecordNode],
|
||||
objectMetadataItems,
|
||||
@ -124,7 +124,7 @@ export const useCreateOneRecord = <
|
||||
const mutationResponseField =
|
||||
getCreateOneRecordMutationResponseField(objectNameSingular);
|
||||
|
||||
const createdObject = await apolloClient
|
||||
const createdObject = await apolloCoreClient
|
||||
.mutate({
|
||||
mutation: createOneRecordMutation,
|
||||
variables: {
|
||||
@ -155,12 +155,12 @@ export const useCreateOneRecord = <
|
||||
deleteRecordFromCache({
|
||||
objectMetadataItems,
|
||||
objectMetadataItem,
|
||||
cache: apolloClient.cache,
|
||||
cache: apolloCoreClient.cache,
|
||||
recordToDestroy: recordCreatedInCache,
|
||||
});
|
||||
|
||||
triggerDestroyRecordsOptimisticEffect({
|
||||
cache: apolloClient.cache,
|
||||
cache: apolloCoreClient.cache,
|
||||
objectMetadataItem,
|
||||
recordsToDestroy: [recordCreatedInCache],
|
||||
objectMetadataItems,
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
import { useApolloClient } from '@apollo/client';
|
||||
|
||||
import { triggerUpdateRecordOptimisticEffectByBatch } from '@/apollo/optimistic-effect/utils/triggerUpdateRecordOptimisticEffectByBatch';
|
||||
import { apiConfigState } from '@/client-config/states/apiConfigState';
|
||||
import { useApolloCoreClient } from '@/object-metadata/hooks/useApolloCoreClient';
|
||||
import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadataItem';
|
||||
import { useObjectMetadataItems } from '@/object-metadata/hooks/useObjectMetadataItems';
|
||||
import { useGetRecordFromCache } from '@/object-record/cache/hooks/useGetRecordFromCache';
|
||||
@ -38,7 +37,7 @@ export const useDeleteManyRecords = ({
|
||||
const mutationPageSize =
|
||||
apiConfig?.mutationMaximumAffectedRecords ?? DEFAULT_MUTATION_BATCH_SIZE;
|
||||
|
||||
const apolloClient = useApolloClient();
|
||||
const apolloCoreClient = useApolloCoreClient();
|
||||
|
||||
const { objectMetadataItem } = useObjectMetadataItem({
|
||||
objectNameSingular,
|
||||
@ -79,7 +78,9 @@ export const useDeleteManyRecords = ({
|
||||
);
|
||||
|
||||
const cachedRecords = batchedIdsToDelete
|
||||
.map((idToDelete) => getRecordFromCache(idToDelete, apolloClient.cache))
|
||||
.map((idToDelete) =>
|
||||
getRecordFromCache(idToDelete, apolloCoreClient.cache),
|
||||
)
|
||||
.filter(isDefined);
|
||||
const currentTimestamp = new Date().toISOString();
|
||||
if (!skipOptimisticEffect) {
|
||||
@ -113,7 +114,7 @@ export const useDeleteManyRecords = ({
|
||||
updateRecordFromCache({
|
||||
objectMetadataItems,
|
||||
objectMetadataItem,
|
||||
cache: apolloClient.cache,
|
||||
cache: apolloCoreClient.cache,
|
||||
record: computedOptimisticRecord,
|
||||
recordGqlFields,
|
||||
objectPermissionsByObjectMetadataId,
|
||||
@ -125,7 +126,7 @@ export const useDeleteManyRecords = ({
|
||||
});
|
||||
|
||||
triggerUpdateRecordOptimisticEffectByBatch({
|
||||
cache: apolloClient.cache,
|
||||
cache: apolloCoreClient.cache,
|
||||
objectMetadataItem,
|
||||
currentRecords: cachedRecordsNode,
|
||||
updatedRecords: computedOptimisticRecordsNode,
|
||||
@ -133,7 +134,7 @@ export const useDeleteManyRecords = ({
|
||||
});
|
||||
}
|
||||
|
||||
const deletedRecordsResponse = await apolloClient
|
||||
const deletedRecordsResponse = await apolloCoreClient
|
||||
.mutate<Record<string, ObjectRecord[]>>({
|
||||
mutation: deleteManyRecordsMutation,
|
||||
variables: {
|
||||
@ -155,7 +156,7 @@ export const useDeleteManyRecords = ({
|
||||
updateRecordFromCache({
|
||||
objectMetadataItems,
|
||||
objectMetadataItem,
|
||||
cache: apolloClient.cache,
|
||||
cache: apolloCoreClient.cache,
|
||||
record: { ...cachedRecord, deletedAt: null },
|
||||
recordGqlFields,
|
||||
objectPermissionsByObjectMetadataId,
|
||||
@ -195,7 +196,7 @@ export const useDeleteManyRecords = ({
|
||||
});
|
||||
|
||||
triggerUpdateRecordOptimisticEffectByBatch({
|
||||
cache: apolloClient.cache,
|
||||
cache: apolloCoreClient.cache,
|
||||
objectMetadataItem,
|
||||
currentRecords: computedOptimisticRecordsNode,
|
||||
updatedRecords: cachedRecordsNode,
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { useApolloClient } from '@apollo/client';
|
||||
import { useCallback } from 'react';
|
||||
|
||||
import { triggerUpdateRecordOptimisticEffect } from '@/apollo/optimistic-effect/utils/triggerUpdateRecordOptimisticEffect';
|
||||
import { useApolloCoreClient } from '@/object-metadata/hooks/useApolloCoreClient';
|
||||
import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadataItem';
|
||||
import { useObjectMetadataItems } from '@/object-metadata/hooks/useObjectMetadataItems';
|
||||
import { useGetRecordFromCache } from '@/object-record/cache/hooks/useGetRecordFromCache';
|
||||
@ -23,7 +23,7 @@ type useDeleteOneRecordProps = {
|
||||
export const useDeleteOneRecord = ({
|
||||
objectNameSingular,
|
||||
}: useDeleteOneRecordProps) => {
|
||||
const apolloClient = useApolloClient();
|
||||
const apolloCoreClient = useApolloCoreClient();
|
||||
|
||||
const { objectMetadataItem } = useObjectMetadataItem({
|
||||
objectNameSingular,
|
||||
@ -48,7 +48,10 @@ export const useDeleteOneRecord = ({
|
||||
|
||||
const deleteOneRecord = useCallback(
|
||||
async (idToDelete: string) => {
|
||||
const cachedRecord = getRecordFromCache(idToDelete, apolloClient.cache);
|
||||
const cachedRecord = getRecordFromCache(
|
||||
idToDelete,
|
||||
apolloCoreClient.cache,
|
||||
);
|
||||
const cachedRecordNode = getRecordNodeFromRecord<ObjectRecord>({
|
||||
record: cachedRecord,
|
||||
objectMetadataItem,
|
||||
@ -82,14 +85,14 @@ export const useDeleteOneRecord = ({
|
||||
updateRecordFromCache({
|
||||
objectMetadataItems,
|
||||
objectMetadataItem,
|
||||
cache: apolloClient.cache,
|
||||
cache: apolloCoreClient.cache,
|
||||
record: computedOptimisticRecord,
|
||||
recordGqlFields,
|
||||
objectPermissionsByObjectMetadataId,
|
||||
});
|
||||
|
||||
triggerUpdateRecordOptimisticEffect({
|
||||
cache: apolloClient.cache,
|
||||
cache: apolloCoreClient.cache,
|
||||
objectMetadataItem,
|
||||
currentRecord: cachedRecordNode,
|
||||
updatedRecord: optimisticRecordNode,
|
||||
@ -97,7 +100,7 @@ export const useDeleteOneRecord = ({
|
||||
});
|
||||
}
|
||||
|
||||
const deletedRecord = await apolloClient
|
||||
const deletedRecord = await apolloCoreClient
|
||||
.mutate({
|
||||
mutation: deleteOneRecordMutation,
|
||||
variables: {
|
||||
@ -129,7 +132,7 @@ export const useDeleteOneRecord = ({
|
||||
updateRecordFromCache({
|
||||
objectMetadataItems,
|
||||
objectMetadataItem,
|
||||
cache: apolloClient.cache,
|
||||
cache: apolloCoreClient.cache,
|
||||
record: {
|
||||
...cachedRecord,
|
||||
deletedAt: null,
|
||||
@ -139,7 +142,7 @@ export const useDeleteOneRecord = ({
|
||||
});
|
||||
|
||||
triggerUpdateRecordOptimisticEffect({
|
||||
cache: apolloClient.cache,
|
||||
cache: apolloCoreClient.cache,
|
||||
objectMetadataItem,
|
||||
currentRecord: optimisticRecordNode,
|
||||
updatedRecord: cachedRecordNode,
|
||||
@ -153,7 +156,7 @@ export const useDeleteOneRecord = ({
|
||||
return deletedRecord.data?.[mutationResponseField] ?? null;
|
||||
},
|
||||
[
|
||||
apolloClient,
|
||||
apolloCoreClient,
|
||||
deleteOneRecordMutation,
|
||||
getRecordFromCache,
|
||||
mutationResponseField,
|
||||
|
||||
@ -1,8 +1,7 @@
|
||||
import { useApolloClient } from '@apollo/client';
|
||||
|
||||
import { triggerCreateRecordsOptimisticEffect } from '@/apollo/optimistic-effect/utils/triggerCreateRecordsOptimisticEffect';
|
||||
import { triggerDestroyRecordsOptimisticEffect } from '@/apollo/optimistic-effect/utils/triggerDestroyRecordsOptimisticEffect';
|
||||
import { apiConfigState } from '@/client-config/states/apiConfigState';
|
||||
import { useApolloCoreClient } from '@/object-metadata/hooks/useApolloCoreClient';
|
||||
import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadataItem';
|
||||
import { useObjectMetadataItems } from '@/object-metadata/hooks/useObjectMetadataItems';
|
||||
import { useGetRecordFromCache } from '@/object-record/cache/hooks/useGetRecordFromCache';
|
||||
@ -35,7 +34,7 @@ export const useDestroyManyRecords = ({
|
||||
const mutationPageSize =
|
||||
apiConfig?.mutationMaximumAffectedRecords ?? DEFAULT_MUTATION_BATCH_SIZE;
|
||||
|
||||
const apolloClient = useApolloClient();
|
||||
const apolloCoreClient = useApolloCoreClient();
|
||||
|
||||
const { objectMetadataItem } = useObjectMetadataItem({
|
||||
objectNameSingular,
|
||||
@ -75,10 +74,10 @@ export const useDestroyManyRecords = ({
|
||||
);
|
||||
|
||||
const cachedRecords = batchedIdToDestroy
|
||||
.map((recordId) => getRecordFromCache(recordId, apolloClient.cache))
|
||||
.map((recordId) => getRecordFromCache(recordId, apolloCoreClient.cache))
|
||||
.filter(isDefined);
|
||||
|
||||
const destroyedRecordsResponse = await apolloClient
|
||||
const destroyedRecordsResponse = await apolloCoreClient
|
||||
.mutate<Record<string, ObjectRecord[]>>({
|
||||
mutation: destroyManyRecordsMutation,
|
||||
variables: {
|
||||
@ -117,7 +116,7 @@ export const useDestroyManyRecords = ({
|
||||
.catch((error: Error) => {
|
||||
if (cachedRecords.length > 0 && !skipOptimisticEffect) {
|
||||
triggerCreateRecordsOptimisticEffect({
|
||||
cache: apolloClient.cache,
|
||||
cache: apolloCoreClient.cache,
|
||||
objectMetadataItem,
|
||||
recordsToCreate: cachedRecords,
|
||||
objectMetadataItems,
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
import { useApolloClient } from '@apollo/client';
|
||||
import { useCallback } from 'react';
|
||||
|
||||
import { triggerCreateRecordsOptimisticEffect } from '@/apollo/optimistic-effect/utils/triggerCreateRecordsOptimisticEffect';
|
||||
import { triggerDestroyRecordsOptimisticEffect } from '@/apollo/optimistic-effect/utils/triggerDestroyRecordsOptimisticEffect';
|
||||
import { useApolloCoreClient } from '@/object-metadata/hooks/useApolloCoreClient';
|
||||
import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadataItem';
|
||||
import { useObjectMetadataItems } from '@/object-metadata/hooks/useObjectMetadataItems';
|
||||
import { useGetRecordFromCache } from '@/object-record/cache/hooks/useGetRecordFromCache';
|
||||
@ -19,7 +19,7 @@ type useDestroyOneRecordProps = {
|
||||
export const useDestroyOneRecord = ({
|
||||
objectNameSingular,
|
||||
}: useDestroyOneRecordProps) => {
|
||||
const apolloClient = useApolloClient();
|
||||
const apolloCoreClient = useApolloCoreClient();
|
||||
|
||||
const { objectMetadataItem } = useObjectMetadataItem({
|
||||
objectNameSingular,
|
||||
@ -40,10 +40,10 @@ export const useDestroyOneRecord = ({
|
||||
async (idToDestroy: string) => {
|
||||
const originalRecord = getRecordFromCache(
|
||||
idToDestroy,
|
||||
apolloClient.cache,
|
||||
apolloCoreClient.cache,
|
||||
);
|
||||
|
||||
const deletedRecord = await apolloClient
|
||||
const deletedRecord = await apolloCoreClient
|
||||
.mutate({
|
||||
mutation: destroyOneRecordMutation,
|
||||
variables: { idToDestroy },
|
||||
@ -70,7 +70,7 @@ export const useDestroyOneRecord = ({
|
||||
.catch((error: Error) => {
|
||||
if (isDefined(originalRecord)) {
|
||||
triggerCreateRecordsOptimisticEffect({
|
||||
cache: apolloClient.cache,
|
||||
cache: apolloCoreClient.cache,
|
||||
objectMetadataItem,
|
||||
recordsToCreate: [originalRecord],
|
||||
objectMetadataItems,
|
||||
@ -84,7 +84,7 @@ export const useDestroyOneRecord = ({
|
||||
return deletedRecord.data?.[mutationResponseField] ?? null;
|
||||
},
|
||||
[
|
||||
apolloClient,
|
||||
apolloCoreClient,
|
||||
destroyOneRecordMutation,
|
||||
getRecordFromCache,
|
||||
mutationResponseField,
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
import { Reference, useApolloClient } from '@apollo/client';
|
||||
import { Reference } from '@apollo/client';
|
||||
|
||||
import { useApolloCoreClient } from '@/object-metadata/hooks/useApolloCoreClient';
|
||||
import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadataItem';
|
||||
import { getRefName } from '@/object-record/cache/utils/getRefName';
|
||||
import { modifyRecordFromCache } from '@/object-record/cache/utils/modifyRecordFromCache';
|
||||
@ -14,7 +15,7 @@ export const useDetachRelatedRecordFromRecord = ({
|
||||
recordObjectNameSingular,
|
||||
fieldNameOnRecordObject,
|
||||
}: useDetachRelatedRecordFromRecordProps) => {
|
||||
const apolloClient = useApolloClient();
|
||||
const apolloCoreClient = useApolloCoreClient();
|
||||
|
||||
const { objectMetadataItem } = useObjectMetadataItem({
|
||||
objectNameSingular: recordObjectNameSingular,
|
||||
@ -49,7 +50,7 @@ export const useDetachRelatedRecordFromRecord = ({
|
||||
}) => {
|
||||
modifyRecordFromCache({
|
||||
objectMetadataItem,
|
||||
cache: apolloClient.cache,
|
||||
cache: apolloCoreClient.cache,
|
||||
fieldModifiers: {
|
||||
[fieldNameOnRecordObject]: (
|
||||
fieldNameOnRecordObjectConnection,
|
||||
|
||||
@ -24,6 +24,7 @@ import { OnFindManyRecordsCompleted } from '@/object-record/types/OnFindManyReco
|
||||
import { filterUniqueRecordEdgesByCursor } from '@/object-record/utils/filterUniqueRecordEdgesByCursor';
|
||||
import { getQueryIdentifier } from '@/object-record/utils/getQueryIdentifier';
|
||||
|
||||
import { useApolloCoreClient } from '@/object-metadata/hooks/useApolloCoreClient';
|
||||
import { capitalize, isDefined } from 'twenty-shared/utils';
|
||||
import { cursorFamilyState } from '../states/cursorFamilyState';
|
||||
import { hasNextPageFamilyState } from '../states/hasNextPageFamilyState';
|
||||
@ -76,6 +77,8 @@ export const useFetchMoreRecordsWithPagination = <
|
||||
objectMetadataItem,
|
||||
onCompleted,
|
||||
}: UseFindManyRecordsStateParams<T>) => {
|
||||
const apolloCoreClient = useApolloCoreClient();
|
||||
|
||||
const queryIdentifier = getQueryIdentifier({
|
||||
objectNameSingular,
|
||||
filter,
|
||||
@ -121,6 +124,7 @@ export const useFetchMoreRecordsWithPagination = <
|
||||
lastCursor: isNonEmptyString(lastCursorLocal)
|
||||
? lastCursorLocal
|
||||
: undefined,
|
||||
client: apolloCoreClient,
|
||||
},
|
||||
updateQuery: (prev, { fetchMoreResult }) => {
|
||||
const previousEdges =
|
||||
@ -203,6 +207,7 @@ export const useFetchMoreRecordsWithPagination = <
|
||||
onCompleted,
|
||||
handleFindManyRecordsError,
|
||||
queryIdentifier,
|
||||
apolloCoreClient,
|
||||
],
|
||||
);
|
||||
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import { useQuery } from '@apollo/client';
|
||||
import { useMemo } from 'react';
|
||||
|
||||
import { useApolloCoreClient } from '@/object-metadata/hooks/useApolloCoreClient';
|
||||
import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadataItem';
|
||||
import { ObjectMetadataItemIdentifier } from '@/object-metadata/types/ObjectMetadataItemIdentifier';
|
||||
import { getRecordsFromRecordConnection } from '@/object-record/cache/utils/getRecordsFromRecordConnection';
|
||||
@ -25,6 +26,8 @@ export const useFindDuplicateRecords = <T extends ObjectRecord = ObjectRecord>({
|
||||
}) => {
|
||||
const findDuplicateQueryStateIdentifier = objectNameSingular;
|
||||
|
||||
const apolloCoreClient = useApolloCoreClient();
|
||||
|
||||
const { objectMetadataItem } = useObjectMetadataItem({
|
||||
objectNameSingular,
|
||||
});
|
||||
@ -47,6 +50,7 @@ export const useFindDuplicateRecords = <T extends ObjectRecord = ObjectRecord>({
|
||||
variables: {
|
||||
ids: objectRecordIds,
|
||||
},
|
||||
client: apolloCoreClient,
|
||||
onCompleted: (data) => {
|
||||
onCompleted?.(data[queryResponseField]);
|
||||
},
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
import { useQuery, WatchQueryFetchPolicy } from '@apollo/client';
|
||||
|
||||
import { useApolloCoreClient } from '@/object-metadata/hooks/useApolloCoreClient';
|
||||
import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadataItem';
|
||||
import { ObjectMetadataItemIdentifier } from '@/object-metadata/types/ObjectMetadataItemIdentifier';
|
||||
import { RecordGqlOperationFindManyResult } from '@/object-record/graphql/types/RecordGqlOperationFindManyResult';
|
||||
@ -40,7 +41,7 @@ export const useFindManyRecords = <T extends ObjectRecord = ObjectRecord>({
|
||||
const { objectMetadataItem } = useObjectMetadataItem({
|
||||
objectNameSingular,
|
||||
});
|
||||
|
||||
const apolloCoreClient = useApolloCoreClient();
|
||||
const { findManyRecordsQuery } = useFindManyRecordsQuery({
|
||||
objectNameSingular,
|
||||
recordGqlFields,
|
||||
@ -94,6 +95,7 @@ export const useFindManyRecords = <T extends ObjectRecord = ObjectRecord>({
|
||||
fetchPolicy: fetchPolicy,
|
||||
onCompleted: handleFindManyRecordsCompleted,
|
||||
onError: handleFindManyRecordsError,
|
||||
client: apolloCoreClient,
|
||||
});
|
||||
|
||||
const { fetchMoreRecords, records, hasNextPage } =
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import { useQuery } from '@apollo/client';
|
||||
import { useMemo } from 'react';
|
||||
|
||||
import { useApolloCoreClient } from '@/object-metadata/hooks/useApolloCoreClient';
|
||||
import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadataItem';
|
||||
import { ObjectMetadataItemIdentifier } from '@/object-metadata/types/ObjectMetadataItemIdentifier';
|
||||
import { getRecordFromRecordNode } from '@/object-record/cache/utils/getRecordFromRecordNode';
|
||||
@ -30,6 +31,8 @@ export const useFindOneRecord = <T extends ObjectRecord = ObjectRecord>({
|
||||
objectNameSingular,
|
||||
});
|
||||
|
||||
const apolloCoreClient = useApolloCoreClient();
|
||||
|
||||
const computedRecordGqlFields =
|
||||
recordGqlFields ?? generateDepthOneRecordGqlFields({ objectMetadataItem });
|
||||
|
||||
@ -50,6 +53,7 @@ export const useFindOneRecord = <T extends ObjectRecord = ObjectRecord>({
|
||||
}>(findOneRecordQuery, {
|
||||
skip: !objectMetadataItem || !objectRecordId || skip || !hasReadPermission,
|
||||
variables: { objectRecordId },
|
||||
client: apolloCoreClient,
|
||||
onCompleted: (data) => {
|
||||
const recordWithoutConnection = getRecordFromRecordNode<T>({
|
||||
recordNode: { ...data[objectNameSingular] },
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import { useLazyQuery } from '@apollo/client';
|
||||
import { useRecoilCallback } from 'recoil';
|
||||
|
||||
import { useApolloCoreClient } from '@/object-metadata/hooks/useApolloCoreClient';
|
||||
import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadataItem';
|
||||
import { getRecordsFromRecordConnection } from '@/object-record/cache/utils/getRecordsFromRecordConnection';
|
||||
import { RecordGqlOperationFindManyResult } from '@/object-record/graphql/types/RecordGqlOperationFindManyResult';
|
||||
@ -31,6 +32,8 @@ export const useLazyFindManyRecords = <T extends ObjectRecord = ObjectRecord>({
|
||||
objectNameSingular,
|
||||
});
|
||||
|
||||
const apolloCoreClient = useApolloCoreClient();
|
||||
|
||||
const { findManyRecordsQuery } = useFindManyRecordsQuery({
|
||||
objectNameSingular,
|
||||
recordGqlFields,
|
||||
@ -68,6 +71,7 @@ export const useLazyFindManyRecords = <T extends ObjectRecord = ObjectRecord>({
|
||||
fetchPolicy: 'cache-first',
|
||||
onCompleted: handleFindManyRecordsCompleted,
|
||||
onError: handleFindManyRecordsError,
|
||||
client: apolloCoreClient,
|
||||
});
|
||||
|
||||
const { fetchMoreRecordsLazy } = useLazyFetchMoreRecordsWithPagination<T>({
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
import { useLazyQuery, WatchQueryFetchPolicy } from '@apollo/client';
|
||||
|
||||
import { useApolloCoreClient } from '@/object-metadata/hooks/useApolloCoreClient';
|
||||
import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadataItem';
|
||||
import { ObjectMetadataItemIdentifier } from '@/object-metadata/types/ObjectMetadataItemIdentifier';
|
||||
import { getRecordFromRecordNode } from '@/object-record/cache/utils/getRecordFromRecordNode';
|
||||
@ -29,6 +30,8 @@ export const useLazyFindOneRecord = <T extends ObjectRecord = ObjectRecord>({
|
||||
objectNameSingular,
|
||||
});
|
||||
|
||||
const apolloCoreClient = useApolloCoreClient();
|
||||
|
||||
const { findOneRecordQuery } = useFindOneRecordQuery({
|
||||
objectNameSingular,
|
||||
recordGqlFields:
|
||||
@ -48,6 +51,7 @@ export const useLazyFindOneRecord = <T extends ObjectRecord = ObjectRecord>({
|
||||
await findOneRecord({
|
||||
variables: { objectRecordId },
|
||||
fetchPolicy,
|
||||
client: apolloCoreClient,
|
||||
onCompleted: (data) => {
|
||||
const record = getRecordFromRecordNode<T>({
|
||||
recordNode: data[objectNameSingular],
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
import { currentWorkspaceMemberState } from '@/auth/states/currentWorkspaceMemberState';
|
||||
import { MAX_SEARCH_RESULTS } from '@/command-menu/constants/MaxSearchResults';
|
||||
import { useApolloCoreClient } from '@/object-metadata/hooks/useApolloCoreClient';
|
||||
import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadataItem';
|
||||
import { ObjectMetadataItemIdentifier } from '@/object-metadata/types/ObjectMetadataItemIdentifier';
|
||||
import { SnackBarVariant } from '@/ui/feedback/snack-bar-manager/components/SnackBar';
|
||||
@ -33,6 +34,8 @@ export const useObjectRecordSearchRecords = ({
|
||||
objectNameSingular,
|
||||
});
|
||||
|
||||
const apolloCoreClient = useApolloCoreClient();
|
||||
|
||||
const { enqueueSnackBar } = useSnackBar();
|
||||
|
||||
const { data, loading, error, previousData } = useSearchQuery({
|
||||
@ -48,6 +51,7 @@ export const useObjectRecordSearchRecords = ({
|
||||
includedObjectNameSingulars: [objectNameSingular],
|
||||
},
|
||||
fetchPolicy: fetchPolicy,
|
||||
client: apolloCoreClient,
|
||||
onError: (error) => {
|
||||
logError(
|
||||
`useSearchRecords for "${objectMetadataItem.namePlural}" error : ` +
|
||||
|
||||
@ -1,17 +1,17 @@
|
||||
import { useApolloCoreClient } from '@/object-metadata/hooks/useApolloCoreClient';
|
||||
import { getAggregateQueryName } from '@/object-record/utils/getAggregateQueryName';
|
||||
import { useApolloClient } from '@apollo/client';
|
||||
|
||||
export const useRefetchAggregateQueries = ({
|
||||
objectMetadataNamePlural,
|
||||
}: {
|
||||
objectMetadataNamePlural: string;
|
||||
}) => {
|
||||
const apolloClient = useApolloClient();
|
||||
const apolloCoreClient = useApolloCoreClient();
|
||||
|
||||
const refetchAggregateQueries = async () => {
|
||||
const queryName = getAggregateQueryName(objectMetadataNamePlural);
|
||||
|
||||
await apolloClient.refetchQueries({
|
||||
await apolloCoreClient.refetchQueries({
|
||||
include: [queryName],
|
||||
});
|
||||
};
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
import { useApolloClient } from '@apollo/client';
|
||||
|
||||
import { triggerUpdateRecordOptimisticEffect } from '@/apollo/optimistic-effect/utils/triggerUpdateRecordOptimisticEffect';
|
||||
import { apiConfigState } from '@/client-config/states/apiConfigState';
|
||||
import { useApolloCoreClient } from '@/object-metadata/hooks/useApolloCoreClient';
|
||||
import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadataItem';
|
||||
import { useObjectMetadataItems } from '@/object-metadata/hooks/useObjectMetadataItems';
|
||||
import { useGetRecordFromCache } from '@/object-record/cache/hooks/useGetRecordFromCache';
|
||||
@ -36,7 +35,7 @@ export const useRestoreManyRecords = ({
|
||||
const mutationPageSize =
|
||||
apiConfig?.mutationMaximumAffectedRecords ?? DEFAULT_MUTATION_BATCH_SIZE;
|
||||
|
||||
const apolloClient = useApolloClient();
|
||||
const apolloCoreClient = useApolloCoreClient();
|
||||
|
||||
const { objectMetadataItem } = useObjectMetadataItem({
|
||||
objectNameSingular,
|
||||
@ -73,7 +72,7 @@ export const useRestoreManyRecords = ({
|
||||
|
||||
const cachedRecords = batchedIdsToRestore
|
||||
.map((idToRestore) =>
|
||||
getRecordFromCache(idToRestore, apolloClient.cache),
|
||||
getRecordFromCache(idToRestore, apolloCoreClient.cache),
|
||||
)
|
||||
.filter(isDefined);
|
||||
|
||||
@ -109,13 +108,13 @@ export const useRestoreManyRecords = ({
|
||||
updateRecordFromCache({
|
||||
objectMetadataItems,
|
||||
objectMetadataItem,
|
||||
cache: apolloClient.cache,
|
||||
cache: apolloCoreClient.cache,
|
||||
record: computedOptimisticRecord,
|
||||
recordGqlFields,
|
||||
objectPermissionsByObjectMetadataId,
|
||||
});
|
||||
triggerUpdateRecordOptimisticEffect({
|
||||
cache: apolloClient.cache,
|
||||
cache: apolloCoreClient.cache,
|
||||
objectMetadataItem,
|
||||
currentRecord: cachedRecordWithConnection,
|
||||
updatedRecord: optimisticRecordWithConnection,
|
||||
@ -125,7 +124,7 @@ export const useRestoreManyRecords = ({
|
||||
});
|
||||
}
|
||||
|
||||
const restoredRecordsResponse = await apolloClient
|
||||
const restoredRecordsResponse = await apolloCoreClient
|
||||
.mutate({
|
||||
mutation: restoreManyRecordsMutation,
|
||||
variables: {
|
||||
@ -168,14 +167,14 @@ export const useRestoreManyRecords = ({
|
||||
updateRecordFromCache({
|
||||
objectMetadataItems,
|
||||
objectMetadataItem,
|
||||
cache: apolloClient.cache,
|
||||
cache: apolloCoreClient.cache,
|
||||
record: cachedRecord,
|
||||
recordGqlFields,
|
||||
objectPermissionsByObjectMetadataId,
|
||||
});
|
||||
|
||||
triggerUpdateRecordOptimisticEffect({
|
||||
cache: apolloClient.cache,
|
||||
cache: apolloCoreClient.cache,
|
||||
objectMetadataItem,
|
||||
currentRecord: optimisticRecordWithConnection,
|
||||
updatedRecord: cachedRecordWithConnection,
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
import { useApolloClient } from '@apollo/client';
|
||||
|
||||
import { triggerUpdateRecordOptimisticEffect } from '@/apollo/optimistic-effect/utils/triggerUpdateRecordOptimisticEffect';
|
||||
import { currentWorkspaceMemberState } from '@/auth/states/currentWorkspaceMemberState';
|
||||
import { useApolloCoreClient } from '@/object-metadata/hooks/useApolloCoreClient';
|
||||
import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadataItem';
|
||||
import { useObjectMetadataItems } from '@/object-metadata/hooks/useObjectMetadataItems';
|
||||
import { useGetRecordFromCache } from '@/object-record/cache/hooks/useGetRecordFromCache';
|
||||
@ -37,7 +36,7 @@ export const useUpdateOneRecord = <
|
||||
objectNameSingular,
|
||||
recordGqlFields,
|
||||
}: useUpdateOneRecordProps) => {
|
||||
const apolloClient = useApolloClient();
|
||||
const apolloCoreClient = useApolloCoreClient();
|
||||
|
||||
const { objectMetadataItem } = useObjectMetadataItem({
|
||||
objectNameSingular,
|
||||
@ -75,7 +74,7 @@ export const useUpdateOneRecord = <
|
||||
objectMetadataItem,
|
||||
currentWorkspaceMember: currentWorkspaceMember,
|
||||
recordInput: updateOneRecordInput,
|
||||
cache: apolloClient.cache,
|
||||
cache: apolloCoreClient.cache,
|
||||
objectMetadataItems,
|
||||
objectPermissionsByObjectMetadataId,
|
||||
});
|
||||
@ -118,14 +117,14 @@ export const useUpdateOneRecord = <
|
||||
updateRecordFromCache({
|
||||
objectMetadataItems,
|
||||
objectMetadataItem,
|
||||
cache: apolloClient.cache,
|
||||
cache: apolloCoreClient.cache,
|
||||
record: computedOptimisticRecord,
|
||||
recordGqlFields,
|
||||
objectPermissionsByObjectMetadataId,
|
||||
});
|
||||
|
||||
triggerUpdateRecordOptimisticEffect({
|
||||
cache: apolloClient.cache,
|
||||
cache: apolloCoreClient.cache,
|
||||
objectMetadataItem,
|
||||
currentRecord: cachedRecordWithConnection,
|
||||
updatedRecord: optimisticRecordWithConnection,
|
||||
@ -142,7 +141,7 @@ export const useUpdateOneRecord = <
|
||||
recordInput: updateOneRecordInput,
|
||||
}),
|
||||
};
|
||||
const updatedRecord = await apolloClient
|
||||
const updatedRecord = await apolloCoreClient
|
||||
.mutate({
|
||||
mutation: updateOneRecordMutation,
|
||||
variables: {
|
||||
@ -185,7 +184,7 @@ export const useUpdateOneRecord = <
|
||||
updateRecordFromCache({
|
||||
objectMetadataItems,
|
||||
objectMetadataItem,
|
||||
cache: apolloClient.cache,
|
||||
cache: apolloCoreClient.cache,
|
||||
record: {
|
||||
...cachedRecord,
|
||||
...buildRecordFromKeysWithSameValue(
|
||||
@ -198,7 +197,7 @@ export const useUpdateOneRecord = <
|
||||
});
|
||||
|
||||
triggerUpdateRecordOptimisticEffect({
|
||||
cache: apolloClient.cache,
|
||||
cache: apolloCoreClient.cache,
|
||||
objectMetadataItem,
|
||||
currentRecord: optimisticRecordWithConnection,
|
||||
updatedRecord: cachedRecordWithConnection,
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
import { useQuery } from '@apollo/client';
|
||||
|
||||
import { useApolloCoreClient } from '@/object-metadata/hooks/useApolloCoreClient';
|
||||
import { getRecordsFromRecordConnection } from '@/object-record/cache/utils/getRecordsFromRecordConnection';
|
||||
import { EMPTY_QUERY } from '@/object-record/constants/EmptyQuery';
|
||||
import { RecordGqlOperationSignature } from '@/object-record/graphql/types/RecordGqlOperationSignature';
|
||||
@ -18,6 +19,8 @@ export const useCombinedFindManyRecords = ({
|
||||
operationSignatures,
|
||||
});
|
||||
|
||||
const apolloCoreClient = useApolloCoreClient();
|
||||
|
||||
const queryVariables = generateCombinedFindManyRecordsQueryVariables({
|
||||
operationSignatures,
|
||||
});
|
||||
@ -27,6 +30,7 @@ export const useCombinedFindManyRecords = ({
|
||||
{
|
||||
skip,
|
||||
variables: queryVariables,
|
||||
client: apolloCoreClient,
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
import { useQuery } from '@apollo/client';
|
||||
|
||||
import { useApolloCoreClient } from '@/object-metadata/hooks/useApolloCoreClient';
|
||||
import { ObjectMetadataItem } from '@/object-metadata/types/ObjectMetadataItem';
|
||||
import { EMPTY_QUERY } from '@/object-record/constants/EmptyQuery';
|
||||
import { RecordGqlOperationSignature } from '@/object-record/graphql/types/RecordGqlOperationSignature';
|
||||
@ -24,6 +25,7 @@ export const useCombinedGetTotalCount = ({
|
||||
}) satisfies RecordGqlOperationSignature,
|
||||
);
|
||||
|
||||
const apolloCoreClient = useApolloCoreClient();
|
||||
const findManyQuery = useGenerateCombinedFindManyRecordsQuery({
|
||||
operationSignatures,
|
||||
});
|
||||
@ -32,6 +34,7 @@ export const useCombinedGetTotalCount = ({
|
||||
findManyQuery ?? EMPTY_QUERY,
|
||||
{
|
||||
skip,
|
||||
client: apolloCoreClient,
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import { ApolloClient, gql, useApolloClient } from '@apollo/client';
|
||||
import { ApolloClient, gql } from '@apollo/client';
|
||||
import { isUndefined } from '@sniptt/guards';
|
||||
|
||||
import { useApolloCoreClient } from '@/object-metadata/hooks/useApolloCoreClient';
|
||||
import { objectMetadataItemsState } from '@/object-metadata/states/objectMetadataItemsState';
|
||||
import { ObjectMetadataItem } from '@/object-metadata/types/ObjectMetadataItem';
|
||||
import { mapObjectMetadataToGraphQLQuery } from '@/object-metadata/utils/mapObjectMetadataToGraphQLQuery';
|
||||
@ -16,7 +17,7 @@ import { useRecoilValue } from 'recoil';
|
||||
import { capitalize } from 'twenty-shared/utils';
|
||||
|
||||
export const usePerformCombinedFindManyRecords = () => {
|
||||
const client = useApolloClient();
|
||||
const apolloCoreClient = useApolloCoreClient();
|
||||
const objectMetadataItems = useRecoilValue(objectMetadataItemsState);
|
||||
|
||||
const { objectPermissionsByObjectMetadataId } = useObjectPermissions();
|
||||
@ -121,7 +122,7 @@ export const usePerformCombinedFindManyRecords = () => {
|
||||
operationSignatures: RecordGqlOperationSignature[];
|
||||
client?: ApolloClient<object>;
|
||||
}) => {
|
||||
const apolloClient = customClient || client;
|
||||
const apolloClient = customClient || apolloCoreClient;
|
||||
|
||||
const findManyQuery = generateCombinedFindManyRecordsQuery(
|
||||
operationSignatures,
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { useExportProcessRecordsForCSV } from '@/object-record/object-options-dropdown/hooks/useExportProcessRecordsForCSV';
|
||||
import { renderHook } from '@testing-library/react';
|
||||
import { act } from 'react';
|
||||
import { FieldMetadataType } from '~/generated/graphql';
|
||||
import { FieldMetadataType } from '~/generated-metadata/graphql';
|
||||
|
||||
jest.mock('@/object-metadata/hooks/useObjectMetadataItem', () => ({
|
||||
useObjectMetadataItem: jest.fn(() => ({
|
||||
|
||||
@ -4,7 +4,7 @@ import { ViewComponentInstanceContext } from '@/views/states/contexts/ViewCompon
|
||||
import { renderHook } from '@testing-library/react';
|
||||
import { act } from 'react';
|
||||
import { RecoilRoot } from 'recoil';
|
||||
import { FieldMetadataType } from '~/generated/graphql';
|
||||
import { FieldMetadataType } from '~/generated-metadata/graphql';
|
||||
|
||||
describe('useSearchRecordGroupField', () => {
|
||||
const renderWithContext = (contextValue: any) =>
|
||||
|
||||
@ -7,7 +7,7 @@ import { computeAggregateValueAndLabel } from '@/object-record/record-board/reco
|
||||
import { AggregateOperations } from '@/object-record/record-table/constants/AggregateOperations';
|
||||
import { DateAggregateOperations } from '@/object-record/record-table/constants/DateAggregateOperations';
|
||||
import { enUS } from 'date-fns/locale';
|
||||
import { FieldMetadataType } from '~/generated/graphql';
|
||||
import { FieldMetadataType } from '~/generated-metadata/graphql';
|
||||
|
||||
const MOCK_FIELD_ID = '7d2d7b5e-7b3e-4b4a-8b0a-7b3e4b4a8b0a';
|
||||
|
||||
|
||||
@ -9,7 +9,7 @@ import { assertFieldMetadata } from '@/object-record/record-field/types/guards/a
|
||||
import { isFieldMultiSelect } from '@/object-record/record-field/types/guards/isFieldMultiSelect';
|
||||
import { isFieldMultiSelectValue } from '@/object-record/record-field/types/guards/isFieldMultiSelectValue';
|
||||
import { recordStoreFamilySelector } from '@/object-record/record-store/states/selectors/recordStoreFamilySelector';
|
||||
import { FieldMetadataType } from '~/generated/graphql';
|
||||
import { FieldMetadataType } from '~/generated-metadata/graphql';
|
||||
|
||||
export const useMultiSelectField = () => {
|
||||
const { recordId, fieldDefinition } = useContext(FieldContext);
|
||||
|
||||
@ -4,7 +4,7 @@ import { useRecoilState, useRecoilValue } from 'recoil';
|
||||
import { usePersistField } from '@/object-record/record-field/hooks/usePersistField';
|
||||
import { useRecordFieldInput } from '@/object-record/record-field/hooks/useRecordFieldInput';
|
||||
import { recordStoreFamilySelector } from '@/object-record/record-store/states/selectors/recordStoreFamilySelector';
|
||||
import { FieldMetadataType } from '~/generated/graphql';
|
||||
import { FieldMetadataType } from '~/generated-metadata/graphql';
|
||||
|
||||
import { FieldContext } from '../../contexts/FieldContext';
|
||||
import { FieldSelectValue } from '../../types/FieldMetadata';
|
||||
|
||||
@ -4,7 +4,7 @@ import { useEffect } from 'react';
|
||||
import { useSetRecoilState } from 'recoil';
|
||||
|
||||
import { recordStoreFamilyState } from '@/object-record/record-store/states/recordStoreFamilyState';
|
||||
import { FieldMetadataType } from '~/generated/graphql';
|
||||
import { FieldMetadataType } from '~/generated-metadata/graphql';
|
||||
|
||||
import { FieldContext } from '@/object-record/record-field/contexts/FieldContext';
|
||||
import { RecordFieldComponentInstanceContext } from '@/object-record/record-field/states/contexts/RecordFieldComponentInstanceContext';
|
||||
|
||||
@ -3,7 +3,7 @@ import { expect, fn, userEvent, within } from '@storybook/test';
|
||||
import { useEffect } from 'react';
|
||||
|
||||
import { useSetHotkeyScope } from '@/ui/utilities/hotkey/hooks/useSetHotkeyScope';
|
||||
import { FieldMetadataType } from '~/generated/graphql';
|
||||
import { FieldMetadataType } from '~/generated-metadata/graphql';
|
||||
|
||||
import { FieldContext } from '@/object-record/record-field/contexts/FieldContext';
|
||||
import { RecordFieldComponentInstanceContext } from '@/object-record/record-field/states/contexts/RecordFieldComponentInstanceContext';
|
||||
|
||||
@ -3,7 +3,7 @@ import { expect, fn, userEvent, waitFor, within } from '@storybook/test';
|
||||
import { useEffect, useState } from 'react';
|
||||
|
||||
import { useSetHotkeyScope } from '@/ui/utilities/hotkey/hooks/useSetHotkeyScope';
|
||||
import { FieldMetadataType } from '~/generated/graphql';
|
||||
import { FieldMetadataType } from '~/generated-metadata/graphql';
|
||||
import { SnackBarDecorator } from '~/testing/decorators/SnackBarDecorator';
|
||||
|
||||
import { FieldContext } from '@/object-record/record-field/contexts/FieldContext';
|
||||
|
||||
@ -7,7 +7,7 @@ import { RecordFieldComponentInstanceContext } from '@/object-record/record-fiel
|
||||
import { DEFAULT_CELL_SCOPE } from '@/object-record/record-table/record-table-cell/hooks/useOpenRecordTableCellV2';
|
||||
import { useSetHotkeyScope } from '@/ui/utilities/hotkey/hooks/useSetHotkeyScope';
|
||||
import { Decorator, Meta, StoryObj } from '@storybook/react';
|
||||
import { FieldMetadataType } from '~/generated/graphql';
|
||||
import { FieldMetadataType } from '~/generated-metadata/graphql';
|
||||
import { I18nFrontDecorator } from '~/testing/decorators/I18nFrontDecorator';
|
||||
import { ObjectMetadataItemsDecorator } from '~/testing/decorators/ObjectMetadataItemsDecorator';
|
||||
import { SnackBarDecorator } from '~/testing/decorators/SnackBarDecorator';
|
||||
|
||||
@ -7,7 +7,7 @@ import { FieldContext } from '@/object-record/record-field/contexts/FieldContext
|
||||
import { RecordFieldComponentInstanceContext } from '@/object-record/record-field/states/contexts/RecordFieldComponentInstanceContext';
|
||||
import { DEFAULT_CELL_SCOPE } from '@/object-record/record-table/record-table-cell/hooks/useOpenRecordTableCellV2';
|
||||
import { Decorator, Meta, StoryObj } from '@storybook/react';
|
||||
import { FieldMetadataType } from '~/generated/graphql';
|
||||
import { FieldMetadataType } from '~/generated-metadata/graphql';
|
||||
import { I18nFrontDecorator } from '~/testing/decorators/I18nFrontDecorator';
|
||||
import { SnackBarDecorator } from '~/testing/decorators/SnackBarDecorator';
|
||||
import { useTextField } from '../../../hooks/useTextField';
|
||||
|
||||
@ -3,6 +3,7 @@ import { v4 } from 'uuid';
|
||||
|
||||
import { SEARCH_QUERY } from '@/command-menu/graphql/queries/search';
|
||||
import { useOpenRecordInCommandMenu } from '@/command-menu/hooks/useOpenRecordInCommandMenu';
|
||||
import { useApolloCoreClient } from '@/object-metadata/hooks/useApolloCoreClient';
|
||||
import { FieldMetadataItem } from '@/object-metadata/types/FieldMetadataItem';
|
||||
import { ObjectMetadataItem } from '@/object-metadata/types/ObjectMetadataItem';
|
||||
import { getLabelIdentifierFieldMetadataItem } from '@/object-metadata/utils/getLabelIdentifierFieldMetadataItem';
|
||||
@ -10,7 +11,6 @@ import { useCreateOneRecord } from '@/object-record/hooks/useCreateOneRecord';
|
||||
import { useUpdateOneRecord } from '@/object-record/hooks/useUpdateOneRecord';
|
||||
import { viewableRecordIdState } from '@/object-record/record-right-drawer/states/viewableRecordIdState';
|
||||
import { viewableRecordNameSingularState } from '@/object-record/record-right-drawer/states/viewableRecordNameSingularState';
|
||||
import { useApolloClient } from '@apollo/client';
|
||||
import { getOperationName } from '@apollo/client/utilities';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
import { FieldMetadataType, RelationType } from '~/generated-metadata/graphql';
|
||||
@ -45,7 +45,7 @@ export const useAddNewRecordAndOpenRightDrawer = ({
|
||||
|
||||
const { openRecordInCommandMenu } = useOpenRecordInCommandMenu();
|
||||
|
||||
const apolloClient = useApolloClient();
|
||||
const apolloCoreClient = useApolloCoreClient();
|
||||
|
||||
if (
|
||||
relationObjectMetadataNameSingular === 'workspaceMember' ||
|
||||
@ -109,7 +109,7 @@ export const useAddNewRecordAndOpenRightDrawer = ({
|
||||
setViewableRecordId(newRecordId);
|
||||
setViewableRecordNameSingular(relationObjectMetadataNameSingular);
|
||||
|
||||
apolloClient.refetchQueries({
|
||||
apolloCoreClient.refetchQueries({
|
||||
include: [getOperationName(SEARCH_QUERY) ?? ''],
|
||||
});
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { FieldMetadataType } from '~/generated/graphql';
|
||||
import { FieldMetadataType } from '~/generated-metadata/graphql';
|
||||
|
||||
import { FieldDefinition } from '../FieldDefinition';
|
||||
import { FieldMetadata, FieldSelectMetadata } from '../FieldMetadata';
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user