nexus-prisma
Advanced tools
Comparing version 0.8.0 to 0.8.1-next.1
@@ -97,3 +97,3 @@ "use strict"; | ||
}, | ||
computedInputs: {} | ||
computedInputs: {}, | ||
}; | ||
@@ -273,2 +273,9 @@ class SchemaBuilder { | ||
this.assertFilteringOrOrderingArgNameExists(typeName, field.outputType.type, publisherConfig.alias, publisherConfig, stage); | ||
const mapping = this.dmmf.getMapping(typeName); | ||
const idField = this.dmmf | ||
.getModelOrThrow(typeName) | ||
.fields.find(f => f.isId); | ||
if (!idField) { | ||
throw new Error(`Your Prisma Model ${typeName} does not have an @id field. It's required for nexus-prisma to work.`); | ||
} | ||
const fieldConfig = this.buildFieldConfig({ | ||
@@ -281,4 +288,5 @@ field, | ||
const photon = this.getPhoton(ctx); | ||
const mapping = this.dmmf.getMapping(typeName); | ||
return photon[mapping.plural]['findOne']({ where: { id: root.id } })[field.name](args); | ||
return photon[mapping.plural]['findOne']({ | ||
where: { [idField.name]: root[idField.name] }, | ||
})[field.name](args); | ||
} | ||
@@ -285,0 +293,0 @@ : undefined, |
{ | ||
"name": "nexus-prisma", | ||
"version": "0.8.0", | ||
"version": "0.8.1-next.1", | ||
"main": "dist/index.js", | ||
@@ -36,4 +36,7 @@ "types": "dist/index.d.ts", | ||
"devDependencies": { | ||
"@prisma/client": "^2.0.0-preview020", | ||
"@prisma/cli": "^0.1.31", | ||
"@prisma/client": "^2.0.0-preview020.3", | ||
"@prisma/fetch-engine": "^0.3.52", | ||
"@prisma/lift": "^0.3.384", | ||
"@prisma/sdk": "^0.0.176", | ||
"@types/fs-extra": "^8.0.0", | ||
@@ -43,6 +46,10 @@ "@types/jest": "^24.9.0", | ||
"@types/pluralize": "^0.0.29", | ||
"@types/rimraf": "^2.0.3", | ||
"@types/tmp": "^0.1.0", | ||
"doctoc": "^1.4.0", | ||
"dripip": "^0.5.0", | ||
"get-port": "^5.1.1", | ||
"graphql": "^14.5.4", | ||
"graphql-request": "^1.8.2", | ||
"graphql-yoga": "^1.18.3", | ||
"jest": "^24.9.0", | ||
@@ -52,3 +59,5 @@ "jest-watch-typeahead": "^0.4.0", | ||
"prettier": "^1.17.1", | ||
"prisma2": "^2.0.0-preview020", | ||
"prisma2": "^2.0.0-preview020.3", | ||
"react": "^16.12.0", | ||
"rimraf": "^3.0.1", | ||
"strip-ansi": "^6.0.0", | ||
@@ -55,0 +64,0 @@ "tmp": "^0.1.0", |
@@ -194,3 +194,3 @@ import * as Nexus from 'nexus' | ||
}, | ||
computedInputs: {} | ||
computedInputs: {}, | ||
} | ||
@@ -459,2 +459,13 @@ | ||
) | ||
const mapping = this.dmmf.getMapping(typeName) | ||
const idField = this.dmmf | ||
.getModelOrThrow(typeName) | ||
.fields.find(f => f.isId) | ||
if (!idField) { | ||
throw new Error( | ||
`Your Prisma Model ${typeName} does not have an @id field. It's required for nexus-prisma to work.`, | ||
) | ||
} | ||
const fieldConfig = this.buildFieldConfig({ | ||
@@ -468,5 +479,6 @@ field, | ||
const photon = this.getPhoton(ctx) | ||
const mapping = this.dmmf.getMapping(typeName) | ||
return photon[mapping.plural!] | ||
['findOne']({ where: { id: root.id } }) | ||
['findOne']({ | ||
where: { [idField.name]: root[idField.name] }, | ||
}) | ||
[field.name](args) | ||
@@ -473,0 +485,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
283989
4460
0
30