I have two collections: companies
and people
. I also have this graphql schema
type Company {
id: ID!
...
}
type Person {
id: ID!
...
}
union Customer = Company | Person
type Query {
allCustomers: [Customer!]
}
Right now my resolver looks like this:
allCustomers: async () => {
const [customers, people] = await Promise.all([
Company.find(),
Person.find(),
])
return [...customers, ...people]
}
Is there a beter way to query the database? Or is this ok?