fix one to many relation dynamic query (#2430)
This commit is contained in:
@ -64,11 +64,14 @@ export class CompositeFieldAliasFactory {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const targetTableName = relationMetadata.toObjectMetadata.targetTableName;
|
|
||||||
const relationDirection = deduceRelationDirection(
|
const relationDirection = deduceRelationDirection(
|
||||||
fieldMetadata.objectMetadataId,
|
fieldMetadata.objectMetadataId,
|
||||||
relationMetadata,
|
relationMetadata,
|
||||||
);
|
);
|
||||||
|
const targetTableName =
|
||||||
|
relationDirection == RelationDirection.TO
|
||||||
|
? relationMetadata.fromObjectMetadata.targetTableName
|
||||||
|
: relationMetadata.toObjectMetadata.targetTableName;
|
||||||
|
|
||||||
// If it's a relation destination is of kind MANY, we need to add the collection suffix and extract the args
|
// If it's a relation destination is of kind MANY, we need to add the collection suffix and extract the args
|
||||||
if (
|
if (
|
||||||
@ -78,9 +81,8 @@ export class CompositeFieldAliasFactory {
|
|||||||
const args = getFieldArgumentsByKey(info, fieldKey);
|
const args = getFieldArgumentsByKey(info, fieldKey);
|
||||||
const argsString = this.argsStringFactory.create(
|
const argsString = this.argsStringFactory.create(
|
||||||
args,
|
args,
|
||||||
relationMetadata.toObjectMetadata.fields,
|
relationMetadata.toObjectMetadata.fields ?? [],
|
||||||
);
|
);
|
||||||
|
|
||||||
return `
|
return `
|
||||||
${fieldKey}: ${targetTableName}Collection${
|
${fieldKey}: ${targetTableName}Collection${
|
||||||
argsString ? `(${argsString})` : ''
|
argsString ? `(${argsString})` : ''
|
||||||
@ -88,7 +90,7 @@ export class CompositeFieldAliasFactory {
|
|||||||
${this.fieldsStringFactory.createFieldsStringRecursive(
|
${this.fieldsStringFactory.createFieldsStringRecursive(
|
||||||
info,
|
info,
|
||||||
fieldValue,
|
fieldValue,
|
||||||
relationMetadata.toObjectMetadata.fields,
|
relationMetadata.toObjectMetadata.fields ?? [],
|
||||||
)}
|
)}
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
@ -100,7 +102,7 @@ export class CompositeFieldAliasFactory {
|
|||||||
${this.fieldsStringFactory.createFieldsStringRecursive(
|
${this.fieldsStringFactory.createFieldsStringRecursive(
|
||||||
info,
|
info,
|
||||||
fieldValue,
|
fieldValue,
|
||||||
relationMetadata.toObjectMetadata.fields,
|
relationMetadata.toObjectMetadata.fields ?? [],
|
||||||
)}
|
)}
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|||||||
Reference in New Issue
Block a user