Skip to content

Commit

Permalink
Rename mutation maximum affected records (twentyhq#6042)
Browse files Browse the repository at this point in the history
As per my last comment on twentyhq#6039,
we decided to rename this var
  • Loading branch information
Weiko authored Jun 26, 2024
1 parent 87abc1b commit 1eb9c58
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 13 deletions.
6 changes: 3 additions & 3 deletions packages/twenty-front/src/generated/graphql.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export type Analytics = {

export type ApiConfig = {
__typename?: 'ApiConfig';
mutationMaximumRecordAffected: Scalars['Float'];
mutationMaximumAffectedRecords: Scalars['Float'];
};

export type ApiKeyToken = {
Expand Down Expand Up @@ -1235,7 +1235,7 @@ export type UpdateBillingSubscriptionMutation = { __typename?: 'Mutation', updat
export type GetClientConfigQueryVariables = Exact<{ [key: string]: never; }>;


export type GetClientConfigQuery = { __typename?: 'Query', clientConfig: { __typename?: 'ClientConfig', signInPrefilled: boolean, signUpDisabled: boolean, debugMode: boolean, chromeExtensionId?: string | null, authProviders: { __typename?: 'AuthProviders', google: boolean, password: boolean, microsoft: boolean }, billing: { __typename?: 'Billing', isBillingEnabled: boolean, billingUrl?: string | null, billingFreeTrialDurationInDays?: number | null }, telemetry: { __typename?: 'Telemetry', enabled: boolean }, support: { __typename?: 'Support', supportDriver: string, supportFrontChatId?: string | null }, sentry: { __typename?: 'Sentry', dsn?: string | null, environment?: string | null, release?: string | null }, captcha: { __typename?: 'Captcha', provider?: CaptchaDriverType | null, siteKey?: string | null }, api: { __typename?: 'ApiConfig', mutationMaximumRecordAffected: number } } };
export type GetClientConfigQuery = { __typename?: 'Query', clientConfig: { __typename?: 'ClientConfig', signInPrefilled: boolean, signUpDisabled: boolean, debugMode: boolean, chromeExtensionId?: string | null, authProviders: { __typename?: 'AuthProviders', google: boolean, password: boolean, microsoft: boolean }, billing: { __typename?: 'Billing', isBillingEnabled: boolean, billingUrl?: string | null, billingFreeTrialDurationInDays?: number | null }, telemetry: { __typename?: 'Telemetry', enabled: boolean }, support: { __typename?: 'Support', supportDriver: string, supportFrontChatId?: string | null }, sentry: { __typename?: 'Sentry', dsn?: string | null, environment?: string | null, release?: string | null }, captcha: { __typename?: 'Captcha', provider?: CaptchaDriverType | null, siteKey?: string | null }, api: { __typename?: 'ApiConfig', mutationMaximumAffectedRecords: number } } };

export type SkipSyncEmailOnboardingStepMutationVariables = Exact<{ [key: string]: never; }>;

Expand Down Expand Up @@ -2362,7 +2362,7 @@ export const GetClientConfigDocument = gql`
siteKey
}
api {
mutationMaximumRecordAffected
mutationMaximumAffectedRecords
}
chromeExtensionId
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useEffect } from 'react';
import { useRecoilState, useSetRecoilState } from 'recoil';

import { apiConfigState } from '@/client-config/states/apiConfigState';
import { authProvidersState } from '@/client-config/states/authProvidersState';
import { billingState } from '@/client-config/states/billingState';
import { captchaProviderState } from '@/client-config/states/captchaProviderState';
Expand Down Expand Up @@ -35,6 +36,8 @@ export const ClientConfigProviderEffect = () => {

const setChromeExtensionId = useSetRecoilState(chromeExtensionIdState);

const setApiConfig = useSetRecoilState(apiConfigState);

const { data, loading } = useGetClientConfigQuery({
skip: isClientConfigLoaded,
});
Expand Down Expand Up @@ -68,6 +71,7 @@ export const ClientConfigProviderEffect = () => {
});

setChromeExtensionId(data?.clientConfig?.chromeExtensionId);
setApiConfig(data?.clientConfig?.api);
}
}, [
data,
Expand All @@ -83,6 +87,7 @@ export const ClientConfigProviderEffect = () => {
setIsClientConfigLoaded,
setCaptchaProvider,
setChromeExtensionId,
setApiConfig,
]);

return <></>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const GET_CLIENT_CONFIG = gql`
siteKey
}
api {
mutationMaximumRecordAffected
mutationMaximumAffectedRecords
}
chromeExtensionId
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { createState } from 'twenty-ui';

import { ApiConfig } from '~/generated/graphql';

export const apiConfigState = createState<ApiConfig | null>({
key: 'apiConfigState',
defaultValue: null,
});
2 changes: 1 addition & 1 deletion packages/twenty-server/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,6 @@ SIGN_IN_PREFILLED=true
# CAPTCHA_SECRET_KEY=
# API_RATE_LIMITING_TTL=
# API_RATE_LIMITING_LIMIT=
# MUTATION_MAXIMUM_RECORD_AFFECTED=100
# MUTATION_MAXIMUM_AFFECTED_RECORDS=100
# CHROME_EXTENSION_ID=bggmipldbceihilonnbpgoeclgbkblkp
# PG_SSL_ALLOW_SELF_SIGNED=true
2 changes: 1 addition & 1 deletion packages/twenty-server/.env.test
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ FILE_TOKEN_SECRET=secret_file_token
# MESSAGING_PROVIDER_GMAIL_ENABLED=false
# STORAGE_TYPE=local
# STORAGE_LOCAL_PATH=.local-storage
# MUTATION_MAXIMUM_RECORD_AFFECTED=100
# MUTATION_MAXIMUM_AFFECTED_RECORDS=100
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ export class WorkspaceQueryRunnerService {
args.filter?.id?.in?.forEach((id) => assertIsValidUuid(id));

const maximumRecordAffected = this.environmentService.get(
'MUTATION_MAXIMUM_RECORD_AFFECTED',
'MUTATION_MAXIMUM_AFFECTED_RECORDS',
);
const query = await this.workspaceQueryBuilderFactory.updateMany(args, {
...options,
Expand Down Expand Up @@ -484,7 +484,7 @@ export class WorkspaceQueryRunnerService {
assertMutationNotOnRemoteObject(objectMetadataItem);

const maximumRecordAffected = this.environmentService.get(
'MUTATION_MAXIMUM_RECORD_AFFECTED',
'MUTATION_MAXIMUM_AFFECTED_RECORDS',
);
const query = await this.workspaceQueryBuilderFactory.deleteMany(args, {
...options,
Expand Down Expand Up @@ -691,7 +691,7 @@ export class WorkspaceQueryRunnerService {
errors,
{
atMost: this.environmentService.get(
'MUTATION_MAXIMUM_RECORD_AFFECTED',
'MUTATION_MAXIMUM_AFFECTED_RECORDS',
),
} satisfies PgGraphQLConfig,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class Captcha {
@ObjectType()
class ApiConfig {
@Field(() => Number, { nullable: false })
mutationMaximumRecordAffected: number;
mutationMaximumAffectedRecords: number;
}

@ObjectType()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ export class ClientConfigResolver {
},
chromeExtensionId: this.environmentService.get('CHROME_EXTENSION_ID'),
api: {
mutationMaximumRecordAffected: this.environmentService.get(
'MUTATION_MAXIMUM_RECORD_AFFECTED',
mutationMaximumAffectedRecords: this.environmentService.get(
'MUTATION_MAXIMUM_AFFECTED_RECORDS',
),
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ export class EnvironmentVariables {
@CastToPositiveNumber()
@IsOptional()
@IsNumber()
MUTATION_MAXIMUM_RECORD_AFFECTED = 100;
MUTATION_MAXIMUM_AFFECTED_RECORDS = 100;

REDIS_HOST = '127.0.0.1';

Expand Down

0 comments on commit 1eb9c58

Please sign in to comment.