fix: nested relations not working and relations not prefixed (#2782)

* fix: nested relations n+n

* fix: prefix custom relations

* fix: only apply targetColumnMap when it's a custom object

* fix: force workspaceId to be provided

* fix: toIsCustom -> isToCustom

* fix: remove console.log
This commit is contained in:
Jérémy M
2023-12-01 15:26:48 +01:00
committed by GitHub
parent 6e6f0af26e
commit 474db1e142
28 changed files with 226 additions and 131 deletions
@@ -18,7 +18,7 @@ export class ArgsFactory {
) {}
public create(
{ args, objectMetadata }: ArgsMetadata,
{ args, objectMetadataId }: ArgsMetadata,
options: WorkspaceBuildSchemaOptions,
): GraphQLFieldConfigArgumentMap {
const fieldConfigMap: GraphQLFieldConfigArgumentMap = {};
@@ -65,21 +65,21 @@ export class ArgsFactory {
// Argument is an input type
if (arg.kind) {
const inputType = this.typeDefinitionsStorage.getInputTypeByKey(
objectMetadata.id,
objectMetadataId,
arg.kind,
);
if (!inputType) {
this.logger.error(
`Could not find a GraphQL input type for ${objectMetadata.id}`,
`Could not find a GraphQL input type for ${objectMetadataId}`,
{
objectMetadata,
objectMetadataId,
options,
},
);
throw new Error(
`Could not find a GraphQL input type for ${objectMetadata.id}`,
`Could not find a GraphQL input type for ${objectMetadataId}`,
);
}
@@ -155,7 +155,7 @@ export class ExtendObjectTypeDefinitionFactory {
argsType = this.argsFactory.create(
{
args,
objectMetadata: relationMetadata.toObjectMetadata,
objectMetadataId: relationMetadata.toObjectMetadataId,
},
options,
);
@@ -81,7 +81,7 @@ export class RootTypeFactory {
const argsType = this.argsFactory.create(
{
args,
objectMetadata,
objectMetadataId: objectMetadata.id,
},
options,
);
@@ -1,5 +1,3 @@
import { ObjectMetadataInterface } from 'src/metadata/field-metadata/interfaces/object-metadata.interface';
import { InputTypeDefinitionKind } from 'src/workspace/workspace-schema-builder/factories/input-type-definition.factory';
import { FieldMetadataType } from 'src/metadata/field-metadata/field-metadata.entity';
@@ -15,5 +13,5 @@ export interface ArgsMetadata {
args: {
[key: string]: ArgMetadata;
};
objectMetadata: ObjectMetadataInterface;
objectMetadataId: string;
}