Skip to content

Commit 89a59cc

Browse files
committed
fix: Detect graphql type
close: unlight#148
1 parent 57e3986 commit 89a59cc

File tree

4 files changed

+26
-14
lines changed

4 files changed

+26
-14
lines changed

package.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
}
5353
},
5454
"dependencies": {
55-
"@prisma/generator-helper": "^4.1.0",
55+
"@prisma/generator-helper": "^4.6.1",
5656
"await-event-emitter": "^2.0.2",
5757
"filenamify": "4.X",
5858
"flat": "^5.0.2",
@@ -65,27 +65,27 @@
6565
"ts-morph": ">=11 <=16"
6666
},
6767
"devDependencies": {
68-
"@commitlint/cli": "^17.2.0",
69-
"@commitlint/config-conventional": "^17.2.0",
68+
"@commitlint/cli": "^17.3.0",
69+
"@commitlint/config-conventional": "^17.3.0",
7070
"@nestjs/apollo": "^10.1.6",
7171
"@nestjs/common": "^9.2.0",
7272
"@nestjs/core": "^9.2.0",
7373
"@nestjs/graphql": "^10.1.6",
7474
"@nestjs/platform-express": "^9.2.0",
75-
"@paljs/plugins": "^5.0.2",
76-
"@prisma/client": "^4.1.0",
75+
"@paljs/plugins": "^5.0.3",
76+
"@prisma/client": "^4.6.1",
7777
"@semantic-release/changelog": "^6.0.1",
7878
"@semantic-release/git": "^10.0.1",
7979
"@swc/core": "^1.3.19",
8080
"@swc/helpers": "^0.4.14",
8181
"@swc/register": "^0.1.10",
8282
"@types/flat": "^5.0.2",
83-
"@types/lodash": "^4.14.189",
83+
"@types/lodash": "^4.14.190",
8484
"@types/mocha": "^10.0.0",
8585
"@types/node": "^18.11.9",
8686
"@types/pluralize": "^0.0.29",
87-
"@typescript-eslint/eslint-plugin": "^5.43.0",
88-
"@typescript-eslint/parser": "^5.43.0",
87+
"@typescript-eslint/eslint-plugin": "^5.44.0",
88+
"@typescript-eslint/parser": "^5.44.0",
8989
"apollo-server-express": "^3.10.0",
9090
"c8": "^7.12.0",
9191
"class-transformer": "^0.5.1",
@@ -99,10 +99,10 @@
9999
"eslint-plugin-import": "^2.26.0",
100100
"eslint-plugin-only-warn": "^1.0.3",
101101
"eslint-plugin-prettier": "^4.2.1",
102-
"eslint-plugin-regexp": "^1.10.0",
102+
"eslint-plugin-regexp": "^1.11.0",
103103
"eslint-plugin-simple-import-sort": "^8.0.0",
104104
"eslint-plugin-sort-class-members": "^1.15.2",
105-
"eslint-plugin-unicorn": "^44.0.2",
105+
"eslint-plugin-unicorn": "^45.0.0",
106106
"eslint-plugin-wix-editor": "^3.3.0",
107107
"expect": "^29.3.1",
108108
"ghooks": "^2.0.4",
@@ -113,8 +113,8 @@
113113
"mocha": "^10.1.0",
114114
"ololog": "^1.1.175",
115115
"precise-commits": "^1.0.2",
116-
"prettier": "^2.7.1",
117-
"prisma": "^4.1.0",
116+
"prettier": "^2.8.0",
117+
"prisma": "^4.6.1",
118118
"prisma-graphql-type-decimal": "^2.0.4",
119119
"reflect-metadata": "^0.1.13",
120120
"request": "^2.88.2",

prisma/schema.prisma

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ datasource database {
55

66
generator client {
77
provider = "prisma-client-js"
8-
previewFeatures = ["fullTextSearch"]
8+
previewFeatures = ["fullTextSearch", "fieldReference", "filteredRelationCount"]
99
}
1010

1111
generator nestgraphql {

src/helpers/get-graphql-input-type.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,18 @@ export function getGraphqlInputType(
6060
}
6161
}
6262

63+
if (
64+
(countTypes.scalar === 1 || countTypes.enumTypes === 1) &&
65+
countTypes.fieldRefTypes === 1
66+
) {
67+
result = inputTypes.find(
68+
x => x.location === 'scalar' || x.location === 'enumTypes',
69+
);
70+
if (result) {
71+
return result;
72+
}
73+
}
74+
6375
throw new TypeError(
6476
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
6577
`Cannot get matching input type from ${

src/test/test-generate.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ async function createGeneratorOptions(
121121
}
122122
generator client {
123123
provider = "prisma-client-js"
124-
previewFeatures = ["fullTextSearch", "referentialIntegrity", "fullTextIndex"]
124+
previewFeatures = ["fullTextSearch", "referentialIntegrity", "fullTextIndex", "fieldReference", "filteredRelationCount"]
125125
}
126126
`;
127127
// eslint-disable-next-line prefer-rest-params

0 commit comments

Comments
 (0)