Skip to content

Commit

Permalink
fix: Detect graphql type
Browse files Browse the repository at this point in the history
  • Loading branch information
unlight committed Nov 26, 2022
1 parent 57e3986 commit 89a59cc
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 14 deletions.
24 changes: 12 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
}
},
"dependencies": {
"@prisma/generator-helper": "^4.1.0",
"@prisma/generator-helper": "^4.6.1",
"await-event-emitter": "^2.0.2",
"filenamify": "4.X",
"flat": "^5.0.2",
Expand All @@ -65,27 +65,27 @@
"ts-morph": ">=11 <=16"
},
"devDependencies": {
"@commitlint/cli": "^17.2.0",
"@commitlint/config-conventional": "^17.2.0",
"@commitlint/cli": "^17.3.0",
"@commitlint/config-conventional": "^17.3.0",
"@nestjs/apollo": "^10.1.6",
"@nestjs/common": "^9.2.0",
"@nestjs/core": "^9.2.0",
"@nestjs/graphql": "^10.1.6",
"@nestjs/platform-express": "^9.2.0",
"@paljs/plugins": "^5.0.2",
"@prisma/client": "^4.1.0",
"@paljs/plugins": "^5.0.3",
"@prisma/client": "^4.6.1",
"@semantic-release/changelog": "^6.0.1",
"@semantic-release/git": "^10.0.1",
"@swc/core": "^1.3.19",
"@swc/helpers": "^0.4.14",
"@swc/register": "^0.1.10",
"@types/flat": "^5.0.2",
"@types/lodash": "^4.14.189",
"@types/lodash": "^4.14.190",
"@types/mocha": "^10.0.0",
"@types/node": "^18.11.9",
"@types/pluralize": "^0.0.29",
"@typescript-eslint/eslint-plugin": "^5.43.0",
"@typescript-eslint/parser": "^5.43.0",
"@typescript-eslint/eslint-plugin": "^5.44.0",
"@typescript-eslint/parser": "^5.44.0",
"apollo-server-express": "^3.10.0",
"c8": "^7.12.0",
"class-transformer": "^0.5.1",
Expand All @@ -99,10 +99,10 @@
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-only-warn": "^1.0.3",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-regexp": "^1.10.0",
"eslint-plugin-regexp": "^1.11.0",
"eslint-plugin-simple-import-sort": "^8.0.0",
"eslint-plugin-sort-class-members": "^1.15.2",
"eslint-plugin-unicorn": "^44.0.2",
"eslint-plugin-unicorn": "^45.0.0",
"eslint-plugin-wix-editor": "^3.3.0",
"expect": "^29.3.1",
"ghooks": "^2.0.4",
Expand All @@ -113,8 +113,8 @@
"mocha": "^10.1.0",
"ololog": "^1.1.175",
"precise-commits": "^1.0.2",
"prettier": "^2.7.1",
"prisma": "^4.1.0",
"prettier": "^2.8.0",
"prisma": "^4.6.1",
"prisma-graphql-type-decimal": "^2.0.4",
"reflect-metadata": "^0.1.13",
"request": "^2.88.2",
Expand Down
2 changes: 1 addition & 1 deletion prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ datasource database {

generator client {
provider = "prisma-client-js"
previewFeatures = ["fullTextSearch"]
previewFeatures = ["fullTextSearch", "fieldReference", "filteredRelationCount"]
}

generator nestgraphql {
Expand Down
12 changes: 12 additions & 0 deletions src/helpers/get-graphql-input-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,18 @@ export function getGraphqlInputType(
}
}

if (
(countTypes.scalar === 1 || countTypes.enumTypes === 1) &&
countTypes.fieldRefTypes === 1
) {
result = inputTypes.find(
x => x.location === 'scalar' || x.location === 'enumTypes',
);
if (result) {
return result;
}
}

throw new TypeError(
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
`Cannot get matching input type from ${
Expand Down
2 changes: 1 addition & 1 deletion src/test/test-generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ async function createGeneratorOptions(
}
generator client {
provider = "prisma-client-js"
previewFeatures = ["fullTextSearch", "referentialIntegrity", "fullTextIndex"]
previewFeatures = ["fullTextSearch", "referentialIntegrity", "fullTextIndex", "fieldReference", "filteredRelationCount"]
}
`;
// eslint-disable-next-line prefer-rest-params
Expand Down

0 comments on commit 89a59cc

Please sign in to comment.