应用同步 +无服务器错误:对于不可为 null 的类型无法返回 null:'null'在父“查询”内
这是我的 schema.graphql 文件
type User {
id: Int
email: String
}
type OrgUser {
id: Int
userId: Int
roleId: Int
orgId: Int
firstName: String
lastName: String
title: String
profileImage: String
user: User
}
type onSiteLead {
id: Int
userId: Int
roleId: Int
orgId: Int
firstName: String
lastName: String
title: String
profileImage: String
user: User,
lightColor: String
darkColor: String
}
type Job {
id: Int
name: String
jobDate: String
projectId: Int
resourceId: Int
userId: Int
project: Project
createdAt: String
}
type Customer {
id: Int
name: String
email: String
logo: String
phone: String
orgId: Int
}
type Project {
id: Int
name: String
customerId: String
onSiteLead: onSiteLead
customer: Customer
}
type Resource {
id: Int
name: String
startDate: String
endDate: String
userId: Int
categoryId: Int
lightColor: String
darkColor: String
user: OrgUser
jobs: [Job]
}
type SubCategories {
id: Int
name: String
startDate: String
endDate: String
parenCatId: Int
organizationId: Int
resources: [Resource]
}
type Category {
id: Int
name: String
startDate: String
endDate: String
parenCatId: Int
organizationId: Int
categories: [SubCategories]
resources: [Resource]
}
type SuperCategory {
id: Int
name: String
startDate: String
endDate: String
parenCatId: Int
organizationId: Int
categories: [Category]
resources: [Resource]
}
input jobInput {
id: Int
name: String
jobDate: String
projectId: Int
resourceId: Int
}
input listJobsInput {
startDate: String
endDate: String
superCat: [Int]
cat: [Int]
subCat: [Int]
}
input listCategoriesInput {
startDate: String
endDate: String
}
type listSuperCategories {
id: Int
name: String
startDate: String
endDate: String
parenCatId: Int
organizationId: Int
categories: [listCategories]
}
type listCategories {
id: Int
name: String
startDate: String
endDate: String
parenCatId: Int
organizationId: Int
categories: [listSubCategories]
}
type listSubCategories {
id: Int
name: String
startDate: String
endDate: String
parenCatId: Int
organizationId: Int
}
input jobData {
resourceId: Int!,
jobDate: String!
}
input pasteJobInput {
jobId: Int!
jobData: [jobData]!
}
type Query {
getJob(jobId: Int!): Job!
listJobs(data: listJobsInput): [SuperCategory]!
listCategories(data: listCategoriesInput): [listSuperCategories]!
}
type Mutation {
addJob(job: jobInput!): Job!
deleteJob(jobId: Int!): Int!
updateJob(job: jobInput!): Job!
pasteJob(data: pasteJobInput!): [Job]!
updateProjectLead(projectId: Int, userId: Int): Project!
}
type Subscription {
onAddJob: Job
@aws_subscribe(mutations: ["addJob"])
onDeleteJob: Int
@aws_subscribe(mutations: ["deleteJob"])
onUpdateJob: Job
@aws_subscribe(mutations: ["updateJob"])
onPasteJob: [Job]
@aws_subscribe(mutations: ["pasteJob"])
onUpdateProjectLead: Project
@aws_subscribe(mutations: ["updateProjectLead"])
}
schema {
query: Query
mutation: Mutation
subscription: Subscription
}
当我在部署到 AWS 后尝试调用任何突变或查询(例如 listCategories 查询)时,它给我错误:
“message”:“不能为不可为空的类型返回 null:'null' 当我尝试在本地调用它时,父“查询”
工作正常,我不确定哪里出错了。
Here is my schema.graphql file
type User {
id: Int
email: String
}
type OrgUser {
id: Int
userId: Int
roleId: Int
orgId: Int
firstName: String
lastName: String
title: String
profileImage: String
user: User
}
type onSiteLead {
id: Int
userId: Int
roleId: Int
orgId: Int
firstName: String
lastName: String
title: String
profileImage: String
user: User,
lightColor: String
darkColor: String
}
type Job {
id: Int
name: String
jobDate: String
projectId: Int
resourceId: Int
userId: Int
project: Project
createdAt: String
}
type Customer {
id: Int
name: String
email: String
logo: String
phone: String
orgId: Int
}
type Project {
id: Int
name: String
customerId: String
onSiteLead: onSiteLead
customer: Customer
}
type Resource {
id: Int
name: String
startDate: String
endDate: String
userId: Int
categoryId: Int
lightColor: String
darkColor: String
user: OrgUser
jobs: [Job]
}
type SubCategories {
id: Int
name: String
startDate: String
endDate: String
parenCatId: Int
organizationId: Int
resources: [Resource]
}
type Category {
id: Int
name: String
startDate: String
endDate: String
parenCatId: Int
organizationId: Int
categories: [SubCategories]
resources: [Resource]
}
type SuperCategory {
id: Int
name: String
startDate: String
endDate: String
parenCatId: Int
organizationId: Int
categories: [Category]
resources: [Resource]
}
input jobInput {
id: Int
name: String
jobDate: String
projectId: Int
resourceId: Int
}
input listJobsInput {
startDate: String
endDate: String
superCat: [Int]
cat: [Int]
subCat: [Int]
}
input listCategoriesInput {
startDate: String
endDate: String
}
type listSuperCategories {
id: Int
name: String
startDate: String
endDate: String
parenCatId: Int
organizationId: Int
categories: [listCategories]
}
type listCategories {
id: Int
name: String
startDate: String
endDate: String
parenCatId: Int
organizationId: Int
categories: [listSubCategories]
}
type listSubCategories {
id: Int
name: String
startDate: String
endDate: String
parenCatId: Int
organizationId: Int
}
input jobData {
resourceId: Int!,
jobDate: String!
}
input pasteJobInput {
jobId: Int!
jobData: [jobData]!
}
type Query {
getJob(jobId: Int!): Job!
listJobs(data: listJobsInput): [SuperCategory]!
listCategories(data: listCategoriesInput): [listSuperCategories]!
}
type Mutation {
addJob(job: jobInput!): Job!
deleteJob(jobId: Int!): Int!
updateJob(job: jobInput!): Job!
pasteJob(data: pasteJobInput!): [Job]!
updateProjectLead(projectId: Int, userId: Int): Project!
}
type Subscription {
onAddJob: Job
@aws_subscribe(mutations: ["addJob"])
onDeleteJob: Int
@aws_subscribe(mutations: ["deleteJob"])
onUpdateJob: Job
@aws_subscribe(mutations: ["updateJob"])
onPasteJob: [Job]
@aws_subscribe(mutations: ["pasteJob"])
onUpdateProjectLead: Project
@aws_subscribe(mutations: ["updateProjectLead"])
}
schema {
query: Query
mutation: Mutation
subscription: Subscription
}
When i try to call any mutation or query(for example listCategories Query) after deployment to AWS, it's giving me error:
"message": "Cannot return null for non-nullable type: 'null' within parent 'Query'
It's Working fine when i try to call it locally. I am not sure where I am going wrong.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我刚刚遇到了同样的问题。我的 Lambda 函数处理程序需要一个
async
https://docs.aws.amazon.com/lambda/最新/dg/nodejs-handler.html
I have just had the same issue. My Lambda function handler needed an
async
https://docs.aws.amazon.com/lambda/latest/dg/nodejs-handler.html