GQL Prisma与mongodb和nexus一起写入数据库,即使返回错误
我们目前正在使用prisma(1.34)和mongoDB、nexus(0.11.7)以及nexus prisma(0.3.7) 我们遇到了以下问题: 当使用一个nexus生成的GQL Prisma与mongodb和nexus一起写入数据库,即使返回错误,mongodb,nexus,prisma,prisma-graphql,Mongodb,Nexus,Prisma,Prisma Graphql,我们目前正在使用prisma(1.34)和mongoDB、nexus(0.11.7)以及nexus prisma(0.3.7) 我们遇到了以下问题: 当使用一个nexus生成的突变端点并且在使用该端点时引发错误时-例如: 错误:找不到id值为5e90ed737f8dd933942ee47b的模型用户节点。 错误对象按预期返回给客户端: { "errors": [ { "message": "No Node for the model User with value 5e9
突变
端点并且在使用该端点时引发错误时-例如:
错误:找不到id值为5e90ed737f8dd933942ee47b的模型用户节点。
错误对象按预期返回给客户端:
{
"errors": [
{
"message": "No Node for the model User with value 5e90ed737f8dd933942ee47b for id found.",
"locations": [
{
"line": 2,
"column": 3
}
],
"path": [
"createInformationLog"
],
"extensions": {
"code": "INTERNAL_SERVER_ERROR",
"exception": {
"result": {
"data": null,
"errors": [ ...
但是文档仍然插入/更新到MongoDB中!
有没有人经历过类似的事情
相关代码部分:
const Mutation = prismaObjectType({
name: 'Mutation',
definition: t => {
// expose all mutations generated by prisma
t.prismaFields(['*'])`
}
t.field('signIn', {
...
})
baseSchema.ts
import { makePrismaSchema } from 'nexus-prisma'
import * as path from 'path'
import datamodelInfo from './generated/nexus-prisma'
import { prisma } from './generated/prisma-client'
import { Mutation, Query, User, AuthPayload, EventsCount } from './models'
// provide all the GraphQL types we've implemented
const types = [Mutation, Query, User, AuthPayload, EventsCount]
const baseSchema = makePrismaSchema({
// provide all the GraphQL types we've implemented
types,
// configure the interface to Prisma
prisma: {
datamodelInfo,
client: prisma
},
// specify where Nexus should put the generated files
outputs: {
schema: path.join(__dirname, './generated/schema.graphql'),
typegen: path.join(__dirname, './generated/nexus.ts')
},
// configure nullability of input arguments: All arguments are non-nullable by default
nonNullDefaults: {
input: false,
output: false
},
// configure automatic type resolution for the TS representations of the associated types
typegenAutoConfig: {
sources: [
{
source: path.join(__dirname, './types.ts'),
alias: 'types'
}
],
contextType: 'types.Context'
}
})
export default baseSchema
docker-compose.yml
services:
prisma:
image: prismagraphql/prisma:1.34
ports:
- '4466:4466'
environment:
PRISMA_CONFIG: |
port: 4466
databases:
default:
connector: mongo
uri: mongodb://xxx:xxx@xxxx:27017/admin
现在存在此错误的悬赏:我创建了一个示例项目:现在存在此错误的悬赏:我创建了一个示例项目:
services:
prisma:
image: prismagraphql/prisma:1.34
ports:
- '4466:4466'
environment:
PRISMA_CONFIG: |
port: 4466
databases:
default:
connector: mongo
uri: mongodb://xxx:xxx@xxxx:27017/admin