[WIP] Whole FE migrated (#2517)
* Wip * WIP * Removed concole log * Add relations to workspace init (#2511) * Add relations to workspace init * remove logs * update prefill * add missing isSystem * comment relation fields * Migrate v2 core models to graphql schema (#2509) * migrate v2 core models to graphql schema * Migrate to new workspace member schema * Continue work * migrated-main * Finished accountOwner nested field integration on companies * Introduce bug * Fix --------- Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com> Co-authored-by: Weiko <corentin@twenty.com>
This commit is contained in:
@ -3,6 +3,7 @@ import { Record as IRecord } from 'src/tenant/query-builder/interfaces/record.in
|
||||
export interface PGGraphQLResponse<Data = any> {
|
||||
resolve: {
|
||||
data: Data;
|
||||
errors: any[];
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -100,9 +100,19 @@ export class QueryRunnerService {
|
||||
options: QueryRunnerOptions,
|
||||
): Promise<Record | undefined> {
|
||||
const { workspaceId, targetTableName } = options;
|
||||
|
||||
console.log({
|
||||
workspaceId,
|
||||
targetTableName,
|
||||
});
|
||||
const query = this.queryBuilderFactory.updateOne(args, options);
|
||||
|
||||
console.log({ query });
|
||||
|
||||
const result = await this.execute(query, workspaceId);
|
||||
|
||||
console.log('HEY');
|
||||
|
||||
return this.parseResult<PGGraphQLMutation<Record>>(
|
||||
result,
|
||||
targetTableName,
|
||||
@ -139,15 +149,20 @@ export class QueryRunnerService {
|
||||
workspaceId,
|
||||
)};
|
||||
`);
|
||||
console.log('ho');
|
||||
console.log(query);
|
||||
console.log('ha');
|
||||
|
||||
return workspaceDataSource?.query<PGGraphQLResult>(`
|
||||
const results = await workspaceDataSource?.query<PGGraphQLResult>(`
|
||||
SELECT graphql.resolve($$
|
||||
${query}
|
||||
$$);
|
||||
`);
|
||||
|
||||
console.log(
|
||||
JSON.stringify({
|
||||
results,
|
||||
}),
|
||||
);
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
private parseResult<Result>(
|
||||
@ -157,6 +172,13 @@ export class QueryRunnerService {
|
||||
): Result {
|
||||
const entityKey = `${command}${targetTableName}Collection`;
|
||||
const result = graphqlResult?.[0]?.resolve?.data?.[entityKey];
|
||||
const errors = graphqlResult?.[0]?.resolve?.errors;
|
||||
|
||||
console.log('Result : ', graphqlResult?.[0]?.resolve);
|
||||
|
||||
if (Array.isArray(errors) && errors.length > 0) {
|
||||
console.error('GraphQL errors', errors);
|
||||
}
|
||||
|
||||
if (!result) {
|
||||
throw new BadRequestException('Malformed result from GraphQL query');
|
||||
|
||||
Reference in New Issue
Block a user