Skip to content

Commit 36a014e

Browse files
committed
Add getAllProducts query
1 parent e36262e commit 36a014e

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

graphQL/data/resolvers.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ const resolvers = {
4040
throw new Error(e)
4141
}
4242
},
43+
getAllProducts: async () => {
44+
try {
45+
return await Widgets.find({})
46+
} catch (e) {
47+
throw new Error(e)
48+
}
49+
},
4350
updateProduct: async ({input}) => {
4451
try {
4552
const updateWidgets = Widgets.findOneAndUpdate({_id:input.id}, input,

graphQL/data/schema.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const schema = buildSchema(`
2121
2222
type Query {
2323
getProduct(id: ID): Product
24+
getAllProducts: [Product]
2425
}
2526
"""
2627
input StoreInput {

0 commit comments

Comments
 (0)