Instoring the status type
.
This commit is contained in:
1 parent
59743d7221
commit
8b53cf1539
7 files changed
+35
-2
No files matched your search
@@ -3,6 +3,7 @@ import gql from 'graphql-tag';
|
||||
export const eventMinimalInfo = gql`
|
||||
fragment EventMinimalInfo on events_Event {
|
||||
id
|
||||
status
|
||||
name
|
||||
startDatetime
|
||||
finishDatetime
|
||||
@@ -18,6 +19,7 @@ export const eventMinimalInfo = gql`
|
||||
export const eventFullInfo = gql`
|
||||
fragment EventFullInfo on events_Event {
|
||||
id
|
||||
status
|
||||
name
|
||||
host{
|
||||
alias
|
||||
|
||||
@@ -4,6 +4,7 @@ export const CANCELLED = 'CANCELLED';
|
||||
export const RUNNING = 'RUNNING';
|
||||
export const INTERRUPTED = 'INTERRUPTED';
|
||||
export const FINISHED = 'FINISHED';
|
||||
export const ARCHIVED = 'ARCHIVED';
|
||||
|
||||
export const EventStatusEnum = [
|
||||
UNPUBLISHED,
|
||||
@@ -12,6 +13,7 @@ export const EventStatusEnum = [
|
||||
RUNNING,
|
||||
INTERRUPTED,
|
||||
FINISHED,
|
||||
ARCHIVED,
|
||||
];
|
||||
|
||||
export default EventStatusEnum;
|
||||
@@ -4,6 +4,7 @@ import {
|
||||
} from 'graphql';
|
||||
import { EventType } from '../types';
|
||||
import { Event } from '../../models';
|
||||
import { UNPUBLISHED, ARCHIVED } from '../../enums/EventStatus';
|
||||
|
||||
const args = {
|
||||
minDate: { type: GraphQLInt },
|
||||
@@ -12,6 +13,7 @@ const args = {
|
||||
|
||||
const resolve = (parent, { minDate, maxDate }) => Event.find(
|
||||
Object.assign(
|
||||
{ status: { $nin: [UNPUBLISHED, ARCHIVED] } },
|
||||
minDate || maxDate
|
||||
? {
|
||||
startDatetime:
|
||||
|
||||
@@ -5,6 +5,7 @@ import {
|
||||
} from 'graphql';
|
||||
import { EventType } from '../types';
|
||||
import { Event } from '../../models';
|
||||
import { UNPUBLISHED, ARCHIVED } from '../../enums/EventStatus';
|
||||
|
||||
const args = {
|
||||
hostId: { type: GraphQLString },
|
||||
@@ -14,7 +15,7 @@ const args = {
|
||||
|
||||
const resolve = (parent, { hostId, minDate, maxDate }, context) => Event.find(
|
||||
Object.assign(
|
||||
hostId ? { hostId } : { hostId: context.userId },
|
||||
hostId ? { hostId, status: { $nin: [UNPUBLISHED, ARCHIVED] } } : { hostId: context.userId },
|
||||
minDate || maxDate
|
||||
? {
|
||||
startDatetime:
|
||||
|
||||
@@ -6,6 +6,7 @@ import {
|
||||
} from 'graphql';
|
||||
import { EventType } from '../types';
|
||||
import { Event } from '../../models';
|
||||
import { UNPUBLISHED, ARCHIVED } from '../../enums/EventStatus';
|
||||
|
||||
const args = {
|
||||
teamId: { type: new GraphQLNonNull(GraphQLString) },
|
||||
@@ -15,7 +16,11 @@ const args = {
|
||||
|
||||
const resolve = (parent, { teamId, minDate, maxDate }) => Event.find(
|
||||
Object.assign(
|
||||
{ participants: { $elemMatch: { teamId } } },
|
||||
{
|
||||
participants: { $elemMatch: { teamId } },
|
||||
status: { $nin: [UNPUBLISHED, ARCHIVED] },
|
||||
},
|
||||
|
||||
minDate || maxDate
|
||||
? {
|
||||
startDatetime:
|
||||
|
||||
@@ -12,12 +12,14 @@ import {
|
||||
ParticipantType,
|
||||
PrizeType,
|
||||
} from './index';
|
||||
import EventStatusEnumType from './enum/EventStatus';
|
||||
|
||||
const EventType = new GraphQLObjectType({
|
||||
name: 'Event',
|
||||
description: 'Everything you need to know about an event',
|
||||
fields: () => ({
|
||||
id: { type: GraphQLID },
|
||||
status: { type: EventStatusEnumType },
|
||||
name: { type: GraphQLString },
|
||||
hostId: { type: GraphQLString },
|
||||
description: { type: GraphQLString },
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
import {
|
||||
GraphQLEnumType,
|
||||
} from 'graphql';
|
||||
|
||||
import { EventStatusEnum } from '../../../enums/EventStatus';
|
||||
|
||||
const values = {};
|
||||
EventStatusEnum.forEach((EventStatus) => {
|
||||
values[EventStatus] = { value: EventStatus };
|
||||
});
|
||||
|
||||
const EventStatusEnumType = new GraphQLEnumType({
|
||||
name: 'EventStatusEnum',
|
||||
values,
|
||||
});
|
||||
|
||||
export {
|
||||
EventStatusEnumType as default,
|
||||
};
|
||||
Reference in new issue
Block a user