From 06e496cc6b1196a379d771c91a5c770fe63d4e98 Mon Sep 17 00:00:00 2001 From: Costi Date: Wed, 20 Sep 2023 14:58:24 +0300 Subject: [PATCH 1/2] add missing function --- .../infrastructure/src/prisma/utils.js | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/generators/app/templates/infrastructure/src/prisma/utils.js b/generators/app/templates/infrastructure/src/prisma/utils.js index d26468b..0871de4 100644 --- a/generators/app/templates/infrastructure/src/prisma/utils.js +++ b/generators/app/templates/infrastructure/src/prisma/utils.js @@ -1,3 +1,23 @@ +function cursorPaginationOptions(pager, direction = pager?.direction || 1) { + const { afterId, pageSize, sortBy = 'name' } = pager + const options = afterId + ? { + skip: 1, + cursor: { + id: afterId + } + } + : {} + + return { + ...options, + take: pageSize, + orderBy: { + [sortBy]: direction ? 'asc' : 'desc' + } + } +} + /** * * @param prismaModel Prisma queried model From c52dc9d11ac109d999525f90ba461644e70d130e Mon Sep 17 00:00:00 2001 From: Costi Date: Wed, 20 Sep 2023 15:00:30 +0300 Subject: [PATCH 2/2] add eslint plugin import --- generators/app/templates/infrastructure/.eslintrc.json | 2 +- generators/app/templates/infrastructure/package.json | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/generators/app/templates/infrastructure/.eslintrc.json b/generators/app/templates/infrastructure/.eslintrc.json index 4f2b163..4efa0b5 100644 --- a/generators/app/templates/infrastructure/.eslintrc.json +++ b/generators/app/templates/infrastructure/.eslintrc.json @@ -1,5 +1,5 @@ { - "extends": ["eslint:recommended", "plugin:node/recommended", "plugin:jest/recommended"], + "extends": ["eslint:recommended", "plugin:node/recommended", "plugin:jest/recommended", "plugin:import/recommended"], "parserOptions": { // Only ESLint 6.2.0 and later support ES2020. "ecmaVersion": 2020 diff --git a/generators/app/templates/infrastructure/package.json b/generators/app/templates/infrastructure/package.json index 23c90be..c17da4c 100644 --- a/generators/app/templates/infrastructure/package.json +++ b/generators/app/templates/infrastructure/package.json @@ -133,6 +133,7 @@ "@graphql-eslint/eslint-plugin": "^3.16.0", "cross-env": "7.0.3", "eslint": "^8.35.0", + "eslint-plugin-import": "^2.28.1", "eslint-plugin-jest": "^27.2.1", "eslint-plugin-node": "^11.1.0", "graphql-schema-linter": "^3.0.1",