我想弄清楚如何使用graphql。
我有一个定义如下的模型。
model Request {
id Int @id @default(autoincrement())
skillCategories SkillCategory[]
}
然后,当我试图定义字段类型时,我认为我遵循,将数组字段类型指定如下:
import * as Prisma from "@prisma/client"
import { Field, ObjectType } from "type-
我现在的环境是prisma的图形瑜伽。当试图运行查询时,我会遇到“无法读取未定义的属性‘查询’”错误。我认为这是因为它不能从上下文中读取
这个问题发生在我重构代码和设置Prisma连接时。在启动服务器时,我已经将prisma包含在上下文中,但它似乎在任何地方都不可用。
错误
[nodemon] starting `babel-node src/index.js`
The server is up!
TypeError: Cannot read property 'query' of undefined
at Object.query (G:\laragon\www\en
我正在尝试对包含关系的GraphQL查询应用一些SQL优化。我使用Prisma (版本2.24.1)、Nexus (版本1.0.0)、nexus-plugin-prisma (版本0.35.0)和graphql (版本15.5.0)。
schema.prisma:
model User {
id Int @id @default(autoincrement())
username String
firstName String?
lastName String?
password St
我对使用prisma + graphQL + nestjs有异议。它不断地告诉我,它无法确定graphQL输入类型:"Error:无法确定“父”的GraphQL输入类型("Org")。请确保您的类使用了适当的装饰符。“
这是我的prisma模式
model Org {
id String @id @default(uuid())
name String
parentId String? //an org can have a single parent org
parent Org? @relation("Pare
我正在使用Prisma,Apollo和React。我已经向用户添加了一个图片字段,它在Prisma操场上显示得很好,但在React中它总是返回null,但如果我查询其他字段,它就没问题。我真的很困惑为什么这不能工作,我犯了一个语法错误吗?
datamodel.graphql:
type User {
id: ID! @unique
picture: String
}
schema.graphql:
type User {
id: ID!
picture: String
}
type Query {
user(id: ID!): User
}
我的解析器:
async
我正在使用服务器上的、/GraphQL/ (内置于@nestjs/graphql)//PostgreSQL和客户机上的构建一个类型记录应用程序。
使用此堆栈(当对GraphQL使用代码优先方法时),您需要为每个实体提供以下模式(例如,“User”):
Prisma模型模式(用Prisma自己的Prisma schema语言编写),用于对数据库建模:
model User {
id Int @id @default(autoincrement())
name String
email String @unique
password String
createdAt
在我的graphql-yoga服务器中,我有这样一个模式:
type Play {
id: ID!
frames: [Frame!]!
}
type Frame {
id: ID!
play: Play!
}
query {
play(playId: "myid") {
id
### The error occurs when I uncomment these lines:
# frames {
# id
# }
}
}
我有用于查询的解析器:
return await context.prisma.p
这是错误
“消息”:“无法在GraphQL上下文中找到Prisma客户端。请在上下文”customPrisma“键下提供。”
栈迹
stacktrace": [
"Error: Unable to find Prisma Client in GraphQL context. Please provide it under the `context[\"customPrisma\"]` key.",
" at getPrismaFromContext (webpack-internal:///