Skip to content

Commit

Permalink
Fix requests search bug
Browse files Browse the repository at this point in the history
  • Loading branch information
ayush-goyal committed May 17, 2021
1 parent 6947bb3 commit 981b277
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions server/src/api/resolvers/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,14 +194,16 @@ export const Query: QueryResolvers = {
if (!context.user.admin) {
// then if they are requesting requests for a user that is not themselves
if (args.search.userId && args.search.userId !== context.user.uuid) {
// return an empty array and avoid making a DB query
return [];
return []; // return an empty array and avoid making a DB query
}

// otherwise, restrict their results to just their user ID
searchObj.userId = context.user.uuid;
searchObj.item.location.hidden = false; // don't show hidden locations
searchObj.item.hidden = false; // don't show hidden items
searchObj.userId = context.user.uuid; // otherwise, restrict their results to just their user ID
searchObj.item = {
location: {
hidden: false, // don't show hidden locations
},
hidden: false, // don't show hidden items
};
}

const requests = await prisma.request.findMany({
Expand Down

0 comments on commit 981b277

Please sign in to comment.