如何查询给定graphql联合类型的两个猫鼬集合?

我有两个集合:companiespeople。我也有这个graphql模式

type Company {
  id: ID!
  ...
}

type Person {
  id: ID!
  ...
}

union Customer = Company | Person

type Query {
  allCustomers: [Customer!]
}

现在我的解析器看起来像这样:

allCustomers: async () => {
  const [customers,people] = await Promise.all([
    Company.find(),Person.find(),])
  return [...customers,...people]
}

是否有更好的方法来查询数据库?还是可以吗?

HUNDUNYISI 回答:如何查询给定graphql联合类型的两个猫鼬集合?

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3084450.html

大家都在问