Yesterday while working on a project that includes a next.js front end and an express backend/api.
I have 4 collections in my DB. I am simply trying to query the products collection and get all products. There are ~15k documents in the collection. I did not change anything to do with the query itself, just changes to the font end. One second the query was working fine, the next it was taking minutes to finish.
I have no clue where it went wrong. If anyone has had this happen before let me know.
here is my query:
query Products {
products {
category
code
id
name
sku
}
}
here is my resolver:
products: async () => {
return await Product.find().lean(true)
},
here is my shcema:
type Product {
id: ID!
name: String
code: String
sku: String
category: String
stores:[ProductStore]
vendors: [ProductVendor]
}
type ProductStore {
name: String
price: Float
onHand: Int
onOrder: Float
sales: Float
}
type ProductVendor {
name: String
cost: Float
quantity: Float
}
I went back and tested the queries in Apollo Server and ran into the same issue. All other calls to my other collections are working normally.
Any help would be appreciated.
Thanks