From 91be2a6ff316ab7d3ac6ec110e59082d2fa9f2de Mon Sep 17 00:00:00 2001 From: Nikola Bjelo Date: Sun, 28 Oct 2018 19:00:24 +0100 Subject: [PATCH] Event by host adding a fallback to current user if user not specified --- server/src/schema/queries/EventsByHost.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/server/src/schema/queries/EventsByHost.js b/server/src/schema/queries/EventsByHost.js index 4b2cf35b3..8a6d35848 100644 --- a/server/src/schema/queries/EventsByHost.js +++ b/server/src/schema/queries/EventsByHost.js @@ -1,14 +1,13 @@ import { GraphQLInt, GraphQLList, - GraphQLString, - GraphQLNonNull + GraphQLString } from 'graphql' import { EventType } from '../types' import { Event } from '../../models' const args = { - hostId: { type: new GraphQLNonNull(GraphQLString) }, + hostId: { type: GraphQLString }, minDate: { type: GraphQLInt }, maxDate: { type: GraphQLInt } } @@ -16,7 +15,7 @@ const args = { const resolve = (parent, { hostId, minDate, maxDate }, context) => { return Event.find( Object.assign( - { hostId }, + hostId ? { hostId } : { hostId: context.userId }, minDate || maxDate ? { startDatetime: Object.assign(