[QRQC_2] No implicitAny in twenty-server (#12075)
# Introduction Following https://github.com/twentyhq/twenty/pull/12068 Related with https://github.com/twentyhq/core-team-issues/issues/975 We're enabling `noImplicitAny` handled few use case manually, added a `ts-expect-error` to the others, we should plan to handle them in the future
This commit is contained in:
@ -117,6 +117,7 @@ export abstract class GraphqlQueryBaseResolverService<
|
||||
const computedArgs = (await this.queryRunnerArgsFactory.create(
|
||||
hookedArgs,
|
||||
options,
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
ResolverArgsType[capitalize(operationName)],
|
||||
)) as Input;
|
||||
|
||||
@ -195,6 +196,7 @@ export abstract class GraphqlQueryBaseResolverService<
|
||||
)
|
||||
) {
|
||||
const permissionRequired: SettingPermissionType =
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
SYSTEM_OBJECTS_PERMISSIONS_REQUIREMENTS[
|
||||
objectMetadataItemWithFieldMaps.nameSingular
|
||||
];
|
||||
|
||||
@ -209,6 +209,7 @@ export class GraphqlQueryCreateManyResolverService extends GraphqlQueryBaseResol
|
||||
.filter(Boolean);
|
||||
|
||||
if (fieldValues.length > 0) {
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
whereConditions[field.column] = In(fieldValues);
|
||||
}
|
||||
}
|
||||
|
||||
@ -52,6 +52,7 @@ export class ApiEventEmitterService {
|
||||
objectMetadataNameSingular: objectMetadataItem.nameSingular,
|
||||
action: DatabaseEventAction.UPDATED,
|
||||
events: records.map((record) => {
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
const before = mappedExistingRecords[record.id];
|
||||
const after = record;
|
||||
const diff = objectRecordChangedValues(
|
||||
|
||||
@ -10,6 +10,7 @@ export class ScalarsExplorerService {
|
||||
|
||||
constructor() {
|
||||
this.scalarImplementations = scalars.reduce((acc, scalar) => {
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
acc[scalar.name] = scalar;
|
||||
|
||||
return acc;
|
||||
|
||||
@ -44,6 +44,7 @@ const findFieldNode = (
|
||||
return field;
|
||||
};
|
||||
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
const parseValueNode = (
|
||||
valueNode: ValueNode,
|
||||
variables: GraphQLResolveInfo['variableValues'],
|
||||
@ -62,6 +63,7 @@ const parseValueNode = (
|
||||
return valueNode.values.map((value) => parseValueNode(value, variables));
|
||||
case Kind.OBJECT:
|
||||
return valueNode.fields.reduce((obj, field) => {
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
obj[field.name.value] = parseValueNode(field.value, variables);
|
||||
|
||||
return obj;
|
||||
|
||||
@ -260,12 +260,15 @@ export class QueryRunnerArgsFactory {
|
||||
const overrideFilter = (filterObject: ObjectRecordFilter) => {
|
||||
return Object.entries(filterObject).reduce((acc, [key, value]) => {
|
||||
if (key === 'and' || key === 'or') {
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
acc[key] = value.map((nestedFilter: ObjectRecordFilter) =>
|
||||
overrideFilter(nestedFilter),
|
||||
);
|
||||
} else if (key === 'not') {
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
acc[key] = overrideFilter(value);
|
||||
} else {
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
acc[key] = this.transformFilterValueByType(
|
||||
key,
|
||||
value,
|
||||
|
||||
@ -5,6 +5,7 @@ import {
|
||||
} from 'src/engine/api/graphql/workspace-query-runner/utils/parse-result.util';
|
||||
|
||||
describe('handleSpecialKey', () => {
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
let result;
|
||||
|
||||
beforeEach(() => {
|
||||
@ -13,10 +14,12 @@ describe('handleSpecialKey', () => {
|
||||
|
||||
test('should correctly process a composite key and add it to the result object', () => {
|
||||
handleCompositeKey(
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
result,
|
||||
createCompositeFieldKey('complexField', 'link'),
|
||||
'value1',
|
||||
);
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
expect(result).toEqual({
|
||||
complexField: {
|
||||
link: 'value1',
|
||||
@ -26,15 +29,18 @@ describe('handleSpecialKey', () => {
|
||||
|
||||
test('should add values under the same newKey if called multiple times', () => {
|
||||
handleCompositeKey(
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
result,
|
||||
createCompositeFieldKey('complexField', 'link'),
|
||||
'value1',
|
||||
);
|
||||
handleCompositeKey(
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
result,
|
||||
createCompositeFieldKey('complexField', 'text'),
|
||||
'value2',
|
||||
);
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
expect(result).toEqual({
|
||||
complexField: {
|
||||
link: 'value1',
|
||||
@ -44,7 +50,9 @@ describe('handleSpecialKey', () => {
|
||||
});
|
||||
|
||||
test('should not create a new field if the composite key is not correctly formed', () => {
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
handleCompositeKey(result, 'COMPOSITE___complexField', 'value1');
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
expect(result).toEqual({});
|
||||
});
|
||||
});
|
||||
|
||||
@ -35,6 +35,7 @@ const pgGraphQLErrorMapping: PgGraphQLErrorMapping = {
|
||||
'duplicate key value violates unique constraint': (command, objectName, _) =>
|
||||
new WorkspaceQueryRunnerException(
|
||||
`Cannot ${
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
pgGraphQLCommandMapping[command] ?? command
|
||||
} ${objectName} because it violates a uniqueness constraint.`,
|
||||
WorkspaceQueryRunnerExceptionCode.QUERY_VIOLATES_UNIQUE_CONSTRAINT,
|
||||
@ -42,6 +43,7 @@ const pgGraphQLErrorMapping: PgGraphQLErrorMapping = {
|
||||
'violates foreign key constraint': (command, objectName, _) =>
|
||||
new WorkspaceQueryRunnerException(
|
||||
`Cannot ${
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
pgGraphQLCommandMapping[command] ?? command
|
||||
} ${objectName} because it violates a foreign key constraint.`,
|
||||
WorkspaceQueryRunnerExceptionCode.QUERY_VIOLATES_FOREIGN_KEY_CONSTRAINT,
|
||||
|
||||
@ -110,11 +110,13 @@ export class WorkspaceQueryHookExplorer implements OnModuleInit {
|
||||
contextId,
|
||||
);
|
||||
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
return contextInstance[methodName].call(
|
||||
contextInstance,
|
||||
...executeParams,
|
||||
);
|
||||
} else {
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
return instance[methodName].call(instance, ...executeParams);
|
||||
}
|
||||
}
|
||||
@ -173,6 +175,7 @@ export class WorkspaceQueryHookExplorer implements OnModuleInit {
|
||||
contextId,
|
||||
);
|
||||
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
return contextInstance[methodName].call(
|
||||
contextInstance,
|
||||
executeParams[0],
|
||||
@ -180,6 +183,7 @@ export class WorkspaceQueryHookExplorer implements OnModuleInit {
|
||||
transformedPayload,
|
||||
);
|
||||
} else {
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
return instance[methodName].call(
|
||||
instance,
|
||||
executeParams[0],
|
||||
|
||||
@ -97,6 +97,7 @@ export class WorkspaceResolverFactory {
|
||||
methodName,
|
||||
)
|
||||
) {
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
resolvers.Query[resolverName] = resolverFactory.create({
|
||||
authContext,
|
||||
objectMetadataMaps,
|
||||
@ -120,6 +121,7 @@ export class WorkspaceResolverFactory {
|
||||
throw new Error(`Unknown mutation resolver type: ${methodName}`);
|
||||
}
|
||||
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
resolvers.Mutation[resolverName] = resolverFactory.create({
|
||||
authContext,
|
||||
objectMetadataMaps,
|
||||
|
||||
@ -37,6 +37,7 @@ export class InputTypeDefinitionFactory {
|
||||
kind: InputTypeDefinitionKind,
|
||||
options: WorkspaceBuildSchemaOptions,
|
||||
): InputTypeDefinition {
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
const inputType = new GraphQLInputObjectType({
|
||||
name: `${pascalCase(objectMetadata.nameSingular)}${kind.toString()}Input`,
|
||||
description: objectMetadata.description,
|
||||
@ -46,6 +47,7 @@ export class InputTypeDefinitionFactory {
|
||||
* Filter input type has additional fields for filtering and is self referencing
|
||||
*/
|
||||
case InputTypeDefinitionKind.Filter: {
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
const andOrType = this.typeMapperService.mapToGqlType(inputType, {
|
||||
isArray: true,
|
||||
arrayDepth: 1,
|
||||
|
||||
@ -172,6 +172,7 @@ export class TypeDefinitionsGenerator {
|
||||
) {
|
||||
const objectTypeDefs = objectMetadataCollection.map((objectMetadata) =>
|
||||
this.objectTypeDefinitionFactory.create(
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
objectMetadata,
|
||||
ObjectTypeDefinitionKind.Plain,
|
||||
options,
|
||||
|
||||
@ -104,12 +104,14 @@ export const generateFields = <
|
||||
throw new Error('Join column name is not defined');
|
||||
}
|
||||
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
fields[joinColumnName] = {
|
||||
type,
|
||||
description: fieldMetadata.description,
|
||||
};
|
||||
}
|
||||
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
fields[fieldMetadata.name] = {
|
||||
type,
|
||||
description: fieldMetadata.description,
|
||||
|
||||
Reference in New Issue
Block a user