feat: pagination with total count (#3384)

* feat: add totalCount

* feat: add command for production to fix existing tables
This commit is contained in:
Jérémy M
2024-01-12 10:41:38 +01:00
committed by GitHub
parent 9ecc3bdbf2
commit d0ed9ee2e0
4 changed files with 62 additions and 1 deletions

View File

@ -140,6 +140,11 @@ export class WorkspaceMigrationRunnerService {
}),
true,
);
// Enable totalCount for the table
await queryRunner.query(`
COMMENT ON TABLE "${schemaName}"."${tableName}" IS '@graphql({"totalCount": {"enabled": true}})';
`);
}
/**

View File

@ -1,6 +1,6 @@
import { Injectable, Logger } from '@nestjs/common';
import { GraphQLFieldConfigMap, GraphQLObjectType } from 'graphql';
import { GraphQLFieldConfigMap, GraphQLInt, GraphQLObjectType } from 'graphql';
import { WorkspaceBuildSchemaOptions } from 'src/workspace/workspace-schema-builder/interfaces/workspace-build-schema-optionts.interface';
import { ObjectMetadataInterface } from 'src/metadata/field-metadata/interfaces/object-metadata.interface';
@ -71,6 +71,11 @@ export class ConnectionTypeDefinitionFactory {
),
};
fields.totalCount = {
type: GraphQLInt,
description: 'Total number of records in the connection',
};
return fields;
}
}