From ee09df7dee16a7b44711159c60c54cc9365be35e Mon Sep 17 00:00:00 2001 From: Wes Bos Date: Tue, 14 Aug 2018 15:39:34 -0400 Subject: stepped --- finished-application/backend/src/resolvers/Query.js | 7 +++++++ finished-application/backend/src/schema.graphql | 1 + 2 files changed, 8 insertions(+) (limited to 'finished-application/backend') diff --git a/finished-application/backend/src/resolvers/Query.js b/finished-application/backend/src/resolvers/Query.js index 51c2c42..a51ead5 100644 --- a/finished-application/backend/src/resolvers/Query.js +++ b/finished-application/backend/src/resolvers/Query.js @@ -5,6 +5,13 @@ const { forwardTo } = require('prisma-binding'); const Query = { items: forwardTo('db'), itemsConnection: forwardTo('db'), + async users(parent, args, ctx, info) { + if (!ctx.request.userId) { + throw new Error('Insufficient Permissions'); + } + + return ctx.db.query.users({}, info); + }, async order(parent, args, ctx, info) { // 1. make sure they are signed in diff --git a/finished-application/backend/src/schema.graphql b/finished-application/backend/src/schema.graphql index 07533eb..9c4a200 100644 --- a/finished-application/backend/src/schema.graphql +++ b/finished-application/backend/src/schema.graphql @@ -3,6 +3,7 @@ type Query { me: User + users: [User]! order(id: ID!): Order! orders(where: OrderWhereInput, orderBy: OrderOrderByInput, skip: Int, after: String, before: String, first: Int, last: Int): [Order]! items(where: ItemWhereInput, orderBy: ItemOrderByInput, skip: Int, after: String, before: String, first: Int, last: Int): [Item]! -- cgit v1.3