应用同步 +无服务器错误:对于不可为 null 的类型无法返回 null:'null'在父“查询”内

发布于 2025-01-09 07:56:37 字数 3320 浏览 0 评论 0原文

这是我的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夏尔 2025-01-16 07:56:38

我刚刚遇到了同样的问题。我的 Lambda 函数处理程序需要一个async

函数必须使用 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

Functions must use the async keyword to use these methods to return a response or error.

https://docs.aws.amazon.com/lambda/latest/dg/nodejs-handler.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文