Complete refactoring
This commit is contained in:
1 parent
1c7b350001
commit
959f9668e6
38 files changed
+704
-413
No files matched your search
@@ -1,40 +0,0 @@
|
||||
import mongoose, { Schema } from 'mongoose'
|
||||
|
||||
const competitionSchema = new Schema({
|
||||
codeName: String,
|
||||
displayName: String,
|
||||
host: String,
|
||||
description: String,
|
||||
startDatetime: Number,
|
||||
finishDatetime: Number,
|
||||
formula: String,
|
||||
plotter: {
|
||||
codeName: String,
|
||||
host: String,
|
||||
repo: String,
|
||||
moduleName: String
|
||||
},
|
||||
rules: [{
|
||||
number: Number,
|
||||
title: String,
|
||||
description: String
|
||||
}],
|
||||
prizes: [{
|
||||
position: Number,
|
||||
algoPrize: Number,
|
||||
otherPrizes: [{
|
||||
condition: String,
|
||||
amount: Number,
|
||||
asset: String
|
||||
}]
|
||||
}],
|
||||
participants: [{
|
||||
devTeam: String,
|
||||
bot: String,
|
||||
release: String
|
||||
}]
|
||||
})
|
||||
|
||||
const Competition = mongoose.model('Competition', competitionSchema)
|
||||
|
||||
export default Competition
|
||||
@@ -0,0 +1,46 @@
|
||||
import mongoose, { Schema } from 'mongoose'
|
||||
import Plotter from './plotter'
|
||||
import Formula from './formula'
|
||||
|
||||
const eventSchema = new Schema({
|
||||
designator: String,
|
||||
name: String,
|
||||
hostId: String,
|
||||
description: String,
|
||||
startDatetime: Number,
|
||||
finishDatetime: Number,
|
||||
formula: { type: Schema.Types.ObjectId, ref: Formula.modelName },
|
||||
plotter: { type: Schema.Types.ObjectId, ref: Plotter.modelName },
|
||||
rules: [{
|
||||
position: Number,
|
||||
title: String,
|
||||
description: String
|
||||
}],
|
||||
prizes: [{
|
||||
rank: Number,
|
||||
amount: Number,
|
||||
additional: [{
|
||||
condition: String,
|
||||
amount: Number,
|
||||
asset: String
|
||||
}]
|
||||
}],
|
||||
participants: [{
|
||||
teamId: String,
|
||||
botId: String,
|
||||
releaseId: String
|
||||
}]
|
||||
})
|
||||
|
||||
eventSchema.pre('find', function () {
|
||||
this.populate('formula').populate('plotter')
|
||||
})
|
||||
eventSchema.post('save', function (doc, next) {
|
||||
doc.populate('formula').populate('plotter').execPopulate().then(function () {
|
||||
next()
|
||||
})
|
||||
})
|
||||
|
||||
const Event = mongoose.model('Event', eventSchema)
|
||||
|
||||
export default Event
|
||||
@@ -0,0 +1,11 @@
|
||||
import mongoose, { Schema } from 'mongoose'
|
||||
|
||||
const formulaSchema = new Schema({
|
||||
ownerId: String,
|
||||
isTemplate: Boolean,
|
||||
name: String
|
||||
})
|
||||
|
||||
const Formula = mongoose.model('Formula', formulaSchema)
|
||||
|
||||
export default Formula
|
||||
@@ -0,0 +1,9 @@
|
||||
import Plotter from './plotter'
|
||||
import Event from './event'
|
||||
import Formula from './formula'
|
||||
|
||||
export {
|
||||
Event,
|
||||
Plotter,
|
||||
Formula
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
import mongoose, { Schema } from 'mongoose'
|
||||
|
||||
const plotterSchema = new Schema({
|
||||
ownerId: String,
|
||||
isTemplate: Boolean,
|
||||
name: String,
|
||||
host: String,
|
||||
repo: String,
|
||||
moduleName: String
|
||||
})
|
||||
|
||||
const Plotter = mongoose.model('Plotter', plotterSchema)
|
||||
|
||||
export default Plotter
|
||||
@@ -1,36 +1,35 @@
|
||||
import {
|
||||
GraphQLNonNull,
|
||||
GraphQLID,
|
||||
GraphQLInt,
|
||||
GraphQLString
|
||||
GraphQLInt
|
||||
} from 'graphql'
|
||||
import { CompetitionType } from '../types'
|
||||
import Competition from '../../models/competition'
|
||||
import { EventType } from '../types'
|
||||
import { Event } from '../../models'
|
||||
|
||||
const args = {
|
||||
competitionCodeName: { type: new GraphQLNonNull(GraphQLID) },
|
||||
position: { type: new GraphQLNonNull(GraphQLInt) },
|
||||
algoPrize: { type: new GraphQLNonNull(GraphQLString) }
|
||||
eventDesignator: { type: new GraphQLNonNull(GraphQLID) },
|
||||
rank: { type: new GraphQLNonNull(GraphQLInt) },
|
||||
amount: { type: new GraphQLNonNull(GraphQLInt) }
|
||||
}
|
||||
|
||||
const resolve = (parent, { competitionCodeName, position, algoPrize }, context) => {
|
||||
const resolve = (parent, { eventDesignator, rank, amount }, context) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
Competition.findOne({ codeName: competitionCodeName, host: context.userId }).exec((err, competition) => {
|
||||
if (err || !competition) {
|
||||
Event.findOne({ designator: eventDesignator, hostId: context.userId }).exec((err, event) => {
|
||||
if (err || !event) {
|
||||
reject(err)
|
||||
} else {
|
||||
if (competition.prizes.some(prize => prize.position === position)) {
|
||||
if (event.prizes.some(prize => prize.rank === rank)) {
|
||||
// need to add an error message here TODO
|
||||
resolve(competition)
|
||||
resolve(event)
|
||||
} else {
|
||||
competition.prizes.push({
|
||||
position,
|
||||
algoPrize
|
||||
event.prizes.push({
|
||||
rank,
|
||||
amount
|
||||
})
|
||||
competition.save((err) => {
|
||||
event.save((err) => {
|
||||
if (err) reject(err)
|
||||
else {
|
||||
resolve(competition)
|
||||
resolve(event)
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -41,7 +40,7 @@ const resolve = (parent, { competitionCodeName, position, algoPrize }, context)
|
||||
|
||||
const mutation = {
|
||||
addPrize: {
|
||||
type: CompetitionType,
|
||||
type: EventType,
|
||||
args,
|
||||
resolve
|
||||
}
|
||||
|
||||
@@ -3,37 +3,37 @@ import {
|
||||
GraphQLID,
|
||||
GraphQLString
|
||||
} from 'graphql'
|
||||
import { CompetitionType } from '../types'
|
||||
import Competition from '../../models/competition'
|
||||
import { EventType } from '../types'
|
||||
import { Event } from '../../models'
|
||||
|
||||
const args = {
|
||||
competitionCodeName: { type: new GraphQLNonNull(GraphQLID) },
|
||||
eventDesignator: { type: new GraphQLNonNull(GraphQLID) },
|
||||
title: { type: new GraphQLNonNull(GraphQLString) },
|
||||
description: { type: new GraphQLNonNull(GraphQLString) }
|
||||
}
|
||||
|
||||
const resolve = (parent, { competitionCodeName, title, description }, context) => {
|
||||
const resolve = (parent, { eventDesignator, title, description }, context) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
Competition.findOne({ codeName: competitionCodeName, host: context.userId }).exec((err, competition) => {
|
||||
if (err || !competition) {
|
||||
Event.findOne({ designator: eventDesignator, hostId: context.userId }).exec((err, event) => {
|
||||
if (err || !event) {
|
||||
reject(err)
|
||||
} else {
|
||||
if (competition.rules.some(rule => rule.title === title)) {
|
||||
resolve(competition)
|
||||
if (event.rules.some(rule => rule.title === title)) {
|
||||
resolve(event)
|
||||
} else {
|
||||
let number = 1
|
||||
while (competition.rules.some(rule => rule.number === number)) {
|
||||
number++
|
||||
let position = 1
|
||||
while (event.rules.some(rule => rule.position === position)) {
|
||||
position++
|
||||
}
|
||||
competition.rules.push({
|
||||
number,
|
||||
event.rules.push({
|
||||
position,
|
||||
title,
|
||||
description
|
||||
})
|
||||
competition.save((err) => {
|
||||
event.save((err) => {
|
||||
if (err) reject(err)
|
||||
else {
|
||||
resolve(competition)
|
||||
resolve(event)
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -44,7 +44,7 @@ const resolve = (parent, { competitionCodeName, title, description }, context) =
|
||||
|
||||
const mutation = {
|
||||
addRule: {
|
||||
type: CompetitionType,
|
||||
type: EventType,
|
||||
args,
|
||||
resolve
|
||||
}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
import {
|
||||
GraphQLNonNull,
|
||||
GraphQLString
|
||||
} from 'graphql'
|
||||
import { EventType } from '../types'
|
||||
import { Event, Formula } from '../../models'
|
||||
|
||||
const args = {
|
||||
eventDesignator: { type: new GraphQLNonNull(GraphQLString) },
|
||||
name: { type: new GraphQLNonNull(GraphQLString) }
|
||||
}
|
||||
|
||||
const resolve = (parent, { name, eventDesignator }, context) => {
|
||||
const ownerId = context.userId
|
||||
let newFormula = new Formula({ name, ownerId })
|
||||
return new Promise((resolve, reject) => {
|
||||
Event.findOne({ designator: eventDesignator, hostId: ownerId }).exec((err, event) => {
|
||||
if (err || !event) {
|
||||
reject(err)
|
||||
} else {
|
||||
newFormula.save((err) => {
|
||||
if (err) reject(err)
|
||||
else {
|
||||
}
|
||||
})
|
||||
event.formula = newFormula._id
|
||||
event.save((err) => {
|
||||
if (err) reject(err)
|
||||
else {
|
||||
resolve(event)
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
const mutation = {
|
||||
createAndSetFormula: {
|
||||
type: EventType,
|
||||
args,
|
||||
resolve
|
||||
}
|
||||
}
|
||||
|
||||
export default mutation
|
||||
@@ -0,0 +1,49 @@
|
||||
import {
|
||||
GraphQLNonNull,
|
||||
GraphQLString
|
||||
} from 'graphql'
|
||||
import { EventType } from '../types'
|
||||
import { Event, Plotter } from '../../models'
|
||||
|
||||
const args = {
|
||||
eventDesignator: { type: new GraphQLNonNull(GraphQLString) },
|
||||
name: { type: new GraphQLNonNull(GraphQLString) },
|
||||
host: { type: new GraphQLNonNull(GraphQLString) },
|
||||
repo: { type: new GraphQLNonNull(GraphQLString) },
|
||||
moduleName: { type: new GraphQLNonNull(GraphQLString) }
|
||||
}
|
||||
|
||||
const resolve = (parent, { name, host, repo, moduleName, eventDesignator }, context) => {
|
||||
const ownerId = context.userId
|
||||
let newPlotter = new Plotter({ name, host, repo, moduleName, ownerId })
|
||||
return new Promise((resolve, reject) => {
|
||||
Event.findOne({ designator: eventDesignator, hostId: ownerId }).exec((err, event) => {
|
||||
if (err || !event) {
|
||||
reject(err)
|
||||
} else {
|
||||
newPlotter.save((err) => {
|
||||
if (err) reject(err)
|
||||
else {
|
||||
}
|
||||
})
|
||||
event.plotter = newPlotter._id
|
||||
event.save((err) => {
|
||||
if (err) reject(err)
|
||||
else {
|
||||
resolve(event)
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
const mutation = {
|
||||
createAndSetPlotter: {
|
||||
type: EventType,
|
||||
args,
|
||||
resolve
|
||||
}
|
||||
}
|
||||
|
||||
export default mutation
|
||||
@@ -0,0 +1,33 @@
|
||||
import {
|
||||
GraphQLNonNull,
|
||||
GraphQLString
|
||||
} from 'graphql'
|
||||
import { FormulaType } from '../types'
|
||||
import { Formula } from '../../models'
|
||||
|
||||
const args = {
|
||||
name: { type: new GraphQLNonNull(GraphQLString) }
|
||||
}
|
||||
|
||||
const resolve = (parent, { name }, context) => {
|
||||
const ownerId = context.userId
|
||||
let newFormula = new Formula({ name, ownerId })
|
||||
return new Promise((resolve, reject) => {
|
||||
newFormula.save((err) => {
|
||||
if (err) reject(err)
|
||||
else {
|
||||
resolve(newFormula)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
const mutation = {
|
||||
createFormula: {
|
||||
type: FormulaType,
|
||||
args,
|
||||
resolve
|
||||
}
|
||||
}
|
||||
|
||||
export default mutation
|
||||
@@ -0,0 +1,36 @@
|
||||
import {
|
||||
GraphQLNonNull,
|
||||
GraphQLString
|
||||
} from 'graphql'
|
||||
import { PlotterType } from '../types'
|
||||
import { Plotter } from '../../models'
|
||||
|
||||
const args = {
|
||||
name: { type: new GraphQLNonNull(GraphQLString) },
|
||||
host: { type: new GraphQLNonNull(GraphQLString) },
|
||||
repo: { type: new GraphQLNonNull(GraphQLString) },
|
||||
moduleName: { type: new GraphQLNonNull(GraphQLString) }
|
||||
}
|
||||
|
||||
const resolve = (parent, { name, host, repo, moduleName }, context) => {
|
||||
const ownerId = context.userId
|
||||
let newPlotter = new Plotter({ name, host, repo, moduleName, ownerId })
|
||||
return new Promise((resolve, reject) => {
|
||||
newPlotter.save((err) => {
|
||||
if (err) reject(err)
|
||||
else {
|
||||
resolve(newPlotter)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
const mutation = {
|
||||
createPlotter: {
|
||||
type: PlotterType,
|
||||
args,
|
||||
resolve
|
||||
}
|
||||
}
|
||||
|
||||
export default mutation
|
||||
@@ -1,59 +0,0 @@
|
||||
import {
|
||||
GraphQLNonNull,
|
||||
GraphQLID,
|
||||
GraphQLInt,
|
||||
GraphQLString
|
||||
} from 'graphql'
|
||||
import { CompetitionType } from '../types'
|
||||
import Competition from '../../models/competition'
|
||||
|
||||
const args = {
|
||||
codeName: { type: new GraphQLNonNull(GraphQLID) },
|
||||
displayName: { type: GraphQLString },
|
||||
description: { type: GraphQLString },
|
||||
startDatetime: { type: GraphQLInt },
|
||||
finishDatetime: { type: GraphQLInt },
|
||||
formula: { type: GraphQLString },
|
||||
plotterCodeName: { type: GraphQLString },
|
||||
plotterHost: { type: GraphQLString },
|
||||
plotterRepo: { type: GraphQLString },
|
||||
plotterModuleName: { type: GraphQLString }
|
||||
}
|
||||
|
||||
const resolve = (parent, { codeName, displayName, description, startDatetime, finishDatetime,
|
||||
formula, plotterCodeName, plotterHost, plotterRepo, plotterModuleName }, context) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
Competition.findOne({ codeName, host: context.userId }).exec((err, competition) => {
|
||||
if (err || !competition) {
|
||||
reject(err)
|
||||
} else {
|
||||
competition.displayName = displayName || competition.displayName
|
||||
competition.description = description || competition.description
|
||||
competition.startDatetime = startDatetime || competition.startDatetime
|
||||
competition.finishDatetime = finishDatetime || competition.finishDatetime
|
||||
competition.formula = formula || competition.formula
|
||||
competition.plotter.codeName = plotterCodeName || competition.plotter.codeName
|
||||
competition.plotter.host = plotterHost || competition.plotter.host
|
||||
competition.plotter.repo = plotterRepo || competition.plotter.repo
|
||||
competition.plotter.moduleName = plotterModuleName || competition.plotter.moduleName
|
||||
|
||||
competition.save((err) => {
|
||||
if (err) reject(err)
|
||||
else {
|
||||
resolve(competition)
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
const mutation = {
|
||||
editCompetition: {
|
||||
type: CompetitionType,
|
||||
args,
|
||||
resolve
|
||||
}
|
||||
}
|
||||
|
||||
export default mutation
|
||||
@@ -0,0 +1,52 @@
|
||||
import {
|
||||
GraphQLNonNull,
|
||||
GraphQLID,
|
||||
GraphQLInt,
|
||||
GraphQLString
|
||||
} from 'graphql'
|
||||
import { EventType } from '../types'
|
||||
import { Event } from '../../models'
|
||||
|
||||
const args = {
|
||||
designator: { type: new GraphQLNonNull(GraphQLID) },
|
||||
name: { type: GraphQLString },
|
||||
description: { type: GraphQLString },
|
||||
startDatetime: { type: GraphQLInt },
|
||||
finishDatetime: { type: GraphQLInt },
|
||||
formulaId: { type: GraphQLString },
|
||||
plotterId: { type: GraphQLString }
|
||||
}
|
||||
|
||||
const resolve = (parent, { designator, name, description, startDatetime, finishDatetime, formulaId, plotterId }, context) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
Event.findOne({ designator, hostId: context.userId }).exec((err, event) => {
|
||||
if (err || !event) {
|
||||
reject(err)
|
||||
} else {
|
||||
event.name = name || event.name
|
||||
event.description = description || event.description
|
||||
event.startDatetime = startDatetime || event.startDatetime
|
||||
event.finishDatetime = finishDatetime || event.finishDatetime
|
||||
event.formula = formulaId || event.formula
|
||||
event.plotter = plotterId || event.plotter
|
||||
|
||||
event.save((err) => {
|
||||
if (err) reject(err)
|
||||
else {
|
||||
resolve(event)
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
const mutation = {
|
||||
editEvent: {
|
||||
type: EventType,
|
||||
args,
|
||||
resolve
|
||||
}
|
||||
}
|
||||
|
||||
export default mutation
|
||||
@@ -3,35 +3,35 @@ import {
|
||||
GraphQLID,
|
||||
GraphQLString
|
||||
} from 'graphql'
|
||||
import { CompetitionType } from '../types'
|
||||
import Competition from '../../models/competition'
|
||||
import { EventType } from '../types'
|
||||
import { Event } from '../../models'
|
||||
|
||||
const args = {
|
||||
competitionCodeName: { type: new GraphQLNonNull(GraphQLID) },
|
||||
devTeam: { type: new GraphQLNonNull(GraphQLString) },
|
||||
bot: { type: GraphQLString },
|
||||
release: { type: GraphQLString }
|
||||
eventDesignator: { type: new GraphQLNonNull(GraphQLID) },
|
||||
teamId: { type: new GraphQLNonNull(GraphQLString) },
|
||||
botId: { type: GraphQLString },
|
||||
releaseId: { type: GraphQLString }
|
||||
}
|
||||
|
||||
const resolve = (parent, { competitionCodeName, devTeam, bot, release }, context) => {
|
||||
const resolve = (parent, { eventDesignator, teamId, botId, releaseId }, context) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
Competition.findOne({ codeName: competitionCodeName }).exec((err, competition) => {
|
||||
Event.findOne({ designator: eventDesignator }).exec((err, event) => {
|
||||
if (err) reject(err)
|
||||
else {
|
||||
let participantIndex
|
||||
competition.participants.find((participant, index) => {
|
||||
if (participant.devTeam === devTeam) {
|
||||
event.participants.find((participant, index) => {
|
||||
if (participant.teamId === teamId) {
|
||||
participantIndex = index
|
||||
}
|
||||
})
|
||||
|
||||
competition.participants[participantIndex].bot = bot || competition.participants[participantIndex].bot
|
||||
competition.participants[participantIndex].release = release || competition.participants[participantIndex].release
|
||||
event.participants[participantIndex].botId = botId || event.participants[participantIndex].botId
|
||||
event.participants[participantIndex].releaseId = releaseId || event.participants[participantIndex].releaseId
|
||||
|
||||
competition.save((err) => {
|
||||
event.save((err) => {
|
||||
if (err) reject(err)
|
||||
else {
|
||||
resolve(competition)
|
||||
resolve(event)
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -41,7 +41,7 @@ const resolve = (parent, { competitionCodeName, devTeam, bot, release }, context
|
||||
|
||||
const mutation = {
|
||||
editParticipant: {
|
||||
type: CompetitionType,
|
||||
type: EventType,
|
||||
args,
|
||||
resolve
|
||||
}
|
||||
|
||||
@@ -3,41 +3,41 @@ import {
|
||||
GraphQLID,
|
||||
GraphQLString
|
||||
} from 'graphql'
|
||||
import { CompetitionType } from '../types'
|
||||
import Competition from '../../models/competition'
|
||||
import { EventType } from '../types'
|
||||
import { Event } from '../../models'
|
||||
|
||||
const args = {
|
||||
competitionCodeName: { type: new GraphQLNonNull(GraphQLID) },
|
||||
eventDesignator: { type: new GraphQLNonNull(GraphQLID) },
|
||||
title: { type: new GraphQLNonNull(GraphQLString) },
|
||||
newtitle: { type: GraphQLString },
|
||||
description: { type: GraphQLString }
|
||||
}
|
||||
|
||||
const resolve = (parent, { competitionCodeName, title, newtitle, description }, context) => {
|
||||
const resolve = (parent, { eventDesignator, title, newtitle, description }, context) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
Competition.findOne({ codeName: competitionCodeName, host: context.userId }).exec((err, competition) => {
|
||||
if (err || !competition) {
|
||||
Event.findOne({ designator: eventDesignator, hostId: context.userId }).exec((err, event) => {
|
||||
if (err || !event) {
|
||||
reject(err)
|
||||
} else {
|
||||
let ruleIndex
|
||||
competition.rules.find((rule, index) => {
|
||||
event.rules.find((rule, index) => {
|
||||
if (rule.title === title) {
|
||||
ruleIndex = index
|
||||
}
|
||||
})
|
||||
|
||||
competition.rules[ruleIndex].description = description || competition.rules[ruleIndex].description
|
||||
if (competition.rules.some(rule => rule.title === newtitle)) {
|
||||
event.rules[ruleIndex].description = description || event.rules[ruleIndex].description
|
||||
if (event.rules.some(rule => rule.title === newtitle)) {
|
||||
// need to add an error message here TODO
|
||||
resolve(competition)
|
||||
resolve(event)
|
||||
} else {
|
||||
competition.rules[ruleIndex].title = newtitle || competition.rules[ruleIndex].title
|
||||
event.rules[ruleIndex].title = newtitle || event.rules[ruleIndex].title
|
||||
}
|
||||
|
||||
competition.save((err) => {
|
||||
event.save((err) => {
|
||||
if (err) reject(err)
|
||||
else {
|
||||
resolve(competition)
|
||||
resolve(event)
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -47,7 +47,7 @@ const resolve = (parent, { competitionCodeName, title, newtitle, description },
|
||||
|
||||
const mutation = {
|
||||
editRule: {
|
||||
type: CompetitionType,
|
||||
type: EventType,
|
||||
args,
|
||||
resolve
|
||||
}
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
import {
|
||||
GraphQLNonNull,
|
||||
GraphQLInt,
|
||||
GraphQLString
|
||||
} from 'graphql'
|
||||
import { CompetitionType } from '../types'
|
||||
import Competition from '../../models/competition'
|
||||
import { slugify } from '../../utils/functions'
|
||||
|
||||
const args = {
|
||||
displayName: { type: new GraphQLNonNull(GraphQLString) },
|
||||
description: { type: new GraphQLNonNull(GraphQLString) },
|
||||
startDatetime: { type: new GraphQLNonNull(GraphQLInt) },
|
||||
finishDatetime: { type: new GraphQLNonNull(GraphQLInt) },
|
||||
formula: { type: new GraphQLNonNull(GraphQLString) }
|
||||
}
|
||||
|
||||
const resolve = (parent, { displayName, description, startDatetime, finishDatetime, formula }, context) => {
|
||||
const host = context.userId
|
||||
let newCompetition = new Competition({
|
||||
host,
|
||||
displayName,
|
||||
description,
|
||||
startDatetime,
|
||||
finishDatetime,
|
||||
formula
|
||||
})
|
||||
newCompetition.codeName = slugify(newCompetition.displayName) + '-' + newCompetition._id
|
||||
return new Promise((resolve, reject) => {
|
||||
newCompetition.save((err) => {
|
||||
if (err) reject(err)
|
||||
else {
|
||||
resolve(newCompetition)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
const mutation = {
|
||||
hostCompetition: {
|
||||
type: CompetitionType,
|
||||
args,
|
||||
resolve
|
||||
}
|
||||
}
|
||||
|
||||
export default mutation
|
||||
@@ -0,0 +1,45 @@
|
||||
import {
|
||||
GraphQLNonNull,
|
||||
GraphQLInt,
|
||||
GraphQLString
|
||||
} from 'graphql'
|
||||
import { EventType } from '../types'
|
||||
import { Event } from '../../models'
|
||||
import { slugify } from '../../utils/functions'
|
||||
|
||||
const args = {
|
||||
name: { type: new GraphQLNonNull(GraphQLString) },
|
||||
description: { type: new GraphQLNonNull(GraphQLString) },
|
||||
startDatetime: { type: new GraphQLNonNull(GraphQLInt) },
|
||||
finishDatetime: { type: new GraphQLNonNull(GraphQLInt) }
|
||||
}
|
||||
|
||||
const resolve = (parent, { name, description, startDatetime, finishDatetime }, context) => {
|
||||
const hostId = context.userId
|
||||
let newEvent = new Event({
|
||||
hostId,
|
||||
name,
|
||||
description,
|
||||
startDatetime,
|
||||
finishDatetime
|
||||
})
|
||||
newEvent.designator = slugify(newEvent.name) + '-' + newEvent._id
|
||||
return new Promise((resolve, reject) => {
|
||||
newEvent.save((err) => {
|
||||
if (err) reject(err)
|
||||
else {
|
||||
resolve(newEvent)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
const mutation = {
|
||||
hostEvent: {
|
||||
type: EventType,
|
||||
args,
|
||||
resolve
|
||||
}
|
||||
}
|
||||
|
||||
export default mutation
|
||||
@@ -1,50 +0,0 @@
|
||||
import {
|
||||
GraphQLNonNull,
|
||||
GraphQLID,
|
||||
GraphQLString
|
||||
} from 'graphql'
|
||||
import { CompetitionType } from '../types'
|
||||
import Competition from '../../models/competition'
|
||||
|
||||
const args = {
|
||||
codeName: { type: new GraphQLNonNull(GraphQLID) },
|
||||
devTeam: { type: new GraphQLNonNull(GraphQLString) },
|
||||
bot: { type: new GraphQLNonNull(GraphQLString) },
|
||||
release: { type: new GraphQLNonNull(GraphQLString) }
|
||||
}
|
||||
|
||||
const resolve = (parent, { codeName, devTeam, bot, release }, context) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
Competition.findOne({ codeName }).exec((err, competition) => {
|
||||
if (err) reject(err)
|
||||
else {
|
||||
if (competition.participants.some(participant => participant.devTeam === args.devTeam)) {
|
||||
// need to add an error message here TODO
|
||||
resolve(competition)
|
||||
} else {
|
||||
competition.participants.push({
|
||||
devTeam,
|
||||
bot,
|
||||
release
|
||||
})
|
||||
competition.save((err) => {
|
||||
if (err) reject(err)
|
||||
else {
|
||||
resolve(competition)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
const mutation = {
|
||||
registerToCompetition: {
|
||||
type: CompetitionType,
|
||||
args,
|
||||
resolve
|
||||
}
|
||||
}
|
||||
|
||||
export default mutation
|
||||
@@ -0,0 +1,50 @@
|
||||
import {
|
||||
GraphQLNonNull,
|
||||
GraphQLID,
|
||||
GraphQLString
|
||||
} from 'graphql'
|
||||
import { EventType } from '../types'
|
||||
import { Event } from '../../models'
|
||||
|
||||
const args = {
|
||||
designator: { type: new GraphQLNonNull(GraphQLID) },
|
||||
teamId: { type: new GraphQLNonNull(GraphQLString) },
|
||||
botId: { type: GraphQLString },
|
||||
releaseId: { type: GraphQLString }
|
||||
}
|
||||
|
||||
const resolve = (parent, { designator, teamId, botId, releaseId }, context) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
Event.findOne({ designator }).exec((err, event) => {
|
||||
if (err) reject(err)
|
||||
else {
|
||||
if (event.participants.some(participant => participant.teamId === teamId)) {
|
||||
// need to add an error message here TODO
|
||||
resolve(event)
|
||||
} else {
|
||||
event.participants.push({
|
||||
teamId,
|
||||
botId,
|
||||
releaseId
|
||||
})
|
||||
event.save((err) => {
|
||||
if (err) reject(err)
|
||||
else {
|
||||
resolve(event)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
const mutation = {
|
||||
registerToEvent: {
|
||||
type: EventType,
|
||||
args,
|
||||
resolve
|
||||
}
|
||||
}
|
||||
|
||||
export default mutation
|
||||
@@ -4,34 +4,34 @@ import {
|
||||
GraphQLInt
|
||||
} from 'graphql'
|
||||
import { isBetween } from '../../utils/functions'
|
||||
import { CompetitionType } from '../types'
|
||||
import Competition from '../../models/competition'
|
||||
import { EventType } from '../types'
|
||||
import { Event } from '../../models'
|
||||
|
||||
const args = {
|
||||
competitionCodeName: { type: new GraphQLNonNull(GraphQLID) },
|
||||
fromNumber: { type: new GraphQLNonNull(GraphQLInt) },
|
||||
toNumber: { type: new GraphQLNonNull(GraphQLInt) }
|
||||
eventDesignator: { type: new GraphQLNonNull(GraphQLID) },
|
||||
fromPosition: { type: new GraphQLNonNull(GraphQLInt) },
|
||||
toPosition: { type: new GraphQLNonNull(GraphQLInt) }
|
||||
}
|
||||
|
||||
const resolve = (parent, { competitionCodeName, fromNumber, toNumber }, context) => {
|
||||
const resolve = (parent, { eventDesignator, fromPosition, toPosition }, context) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
Competition.findOne({ codeName: competitionCodeName, host: context.userId }).exec((err, competition) => {
|
||||
if (err || !competition) {
|
||||
Event.findOne({ designator: eventDesignator, hostId: context.userId }).exec((err, event) => {
|
||||
if (err || !event) {
|
||||
reject(err)
|
||||
} else {
|
||||
const delta = fromNumber > toNumber ? 1 : -1
|
||||
competition.rules.forEach((part) => {
|
||||
if (part.number === fromNumber) {
|
||||
part.number = toNumber
|
||||
} else if (isBetween(part.number, fromNumber, toNumber)) {
|
||||
part.number += delta
|
||||
const delta = fromPosition > toPosition ? 1 : -1
|
||||
event.rules.forEach((part) => {
|
||||
if (part.position === fromPosition) {
|
||||
part.position = toPosition
|
||||
} else if (isBetween(part.position, fromPosition, toPosition)) {
|
||||
part.position += delta
|
||||
}
|
||||
})
|
||||
|
||||
competition.save((err) => {
|
||||
event.save((err) => {
|
||||
if (err) reject(err)
|
||||
else {
|
||||
resolve(competition)
|
||||
resolve(event)
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -41,7 +41,7 @@ const resolve = (parent, { competitionCodeName, fromNumber, toNumber }, context)
|
||||
|
||||
const mutation = {
|
||||
reorderRules: {
|
||||
type: CompetitionType,
|
||||
type: EventType,
|
||||
args,
|
||||
resolve
|
||||
}
|
||||
|
||||
@@ -2,26 +2,34 @@ import {
|
||||
GraphQLObjectType
|
||||
} from 'graphql'
|
||||
|
||||
import HostCompetitionMutation from './HostCompetition'
|
||||
import EditCompetitionMutation from './EditCompetition'
|
||||
import RegisterToCompetitionMutation from './RegisterToCompetition'
|
||||
import HostEventMutation from './HostEvent'
|
||||
import EditEventMutation from './EditEvent'
|
||||
import RegisterToEventMutation from './RegisterToEvent'
|
||||
import EditParticipantMutation from './EditParticipant'
|
||||
import AddRuleMutation from './AddRule'
|
||||
import EditRuleMutation from './EditRule'
|
||||
import ReorderRulesMutation from './ReorderRules'
|
||||
import AddPrizeMutation from './AddPrize'
|
||||
import CreateFormulaMutation from './CreateFormula'
|
||||
import CreateAndSetFormulaMutation from './CreateAndSetFormula'
|
||||
import CreatePlotterMutation from './CreatePlotter'
|
||||
import CreateAndSetPlotterMutation from './CreateAndSetPlotter'
|
||||
|
||||
const Mutation = new GraphQLObjectType({
|
||||
name: 'Mutation',
|
||||
fields: Object.assign(
|
||||
HostCompetitionMutation,
|
||||
EditCompetitionMutation,
|
||||
RegisterToCompetitionMutation,
|
||||
HostEventMutation,
|
||||
EditEventMutation,
|
||||
RegisterToEventMutation,
|
||||
EditParticipantMutation,
|
||||
AddRuleMutation,
|
||||
EditRuleMutation,
|
||||
ReorderRulesMutation,
|
||||
AddPrizeMutation
|
||||
AddPrizeMutation,
|
||||
CreateFormulaMutation,
|
||||
CreateAndSetFormulaMutation,
|
||||
CreatePlotterMutation,
|
||||
CreateAndSetPlotterMutation
|
||||
)
|
||||
})
|
||||
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
import {
|
||||
GraphQLBoolean,
|
||||
GraphQLList
|
||||
} from 'graphql'
|
||||
import { epoch } from '../../utils/functions'
|
||||
import { CompetitionType } from '../types'
|
||||
import Competition from '../../models/competition'
|
||||
|
||||
const args = {
|
||||
includeOld: { type: GraphQLBoolean }
|
||||
}
|
||||
|
||||
const resolve = (parent, { includeOld }, context) => {
|
||||
return Competition.find(
|
||||
Object.assign(
|
||||
{},
|
||||
includeOld ? {} : { finishDatetime: { $gt: epoch() } }
|
||||
))
|
||||
}
|
||||
|
||||
const query = {
|
||||
competitions: {
|
||||
type: new GraphQLList(CompetitionType),
|
||||
args,
|
||||
resolve
|
||||
}
|
||||
}
|
||||
|
||||
export default query
|
||||
@@ -1,35 +0,0 @@
|
||||
import {
|
||||
GraphQLBoolean,
|
||||
GraphQLList,
|
||||
GraphQLString,
|
||||
GraphQLNonNull
|
||||
} from 'graphql'
|
||||
import { epoch } from '../../utils/functions'
|
||||
import { CompetitionType } from '../types'
|
||||
import Competition from '../../models/competition'
|
||||
|
||||
const args = {
|
||||
devTeam: { type: new GraphQLNonNull(GraphQLString) },
|
||||
includeOld: { type: GraphQLBoolean }
|
||||
}
|
||||
|
||||
const resolve = (parent, { devTeam, includeOld }, context) => {
|
||||
return Competition.find(
|
||||
Object.assign(
|
||||
{
|
||||
participants: { $elemMatch: { devTeam } }
|
||||
},
|
||||
includeOld ? {} : { finishDatetime: { $gt: epoch() } }
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
const query = {
|
||||
competitionsByDevTeam: {
|
||||
type: new GraphQLList(CompetitionType),
|
||||
args,
|
||||
resolve
|
||||
}
|
||||
}
|
||||
|
||||
export default query
|
||||
@@ -1,35 +0,0 @@
|
||||
import {
|
||||
GraphQLBoolean,
|
||||
GraphQLList,
|
||||
GraphQLString,
|
||||
GraphQLNonNull
|
||||
} from 'graphql'
|
||||
import { epoch } from '../../utils/functions'
|
||||
import { CompetitionType } from '../types'
|
||||
import Competition from '../../models/competition'
|
||||
|
||||
const args = {
|
||||
host: { type: new GraphQLNonNull(GraphQLString) },
|
||||
includeOld: { type: GraphQLBoolean }
|
||||
}
|
||||
|
||||
const resolve = (parent, { host, includeOld }, context) => {
|
||||
return Competition.find(
|
||||
Object.assign(
|
||||
{
|
||||
host
|
||||
},
|
||||
includeOld ? {} : { finishDatetime: { $gt: epoch() } }
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
const query = {
|
||||
competitionsByHost: {
|
||||
type: new GraphQLList(CompetitionType),
|
||||
args,
|
||||
resolve
|
||||
}
|
||||
}
|
||||
|
||||
export default query
|
||||
@@ -0,0 +1,35 @@
|
||||
import {
|
||||
GraphQLInt,
|
||||
GraphQLList
|
||||
} from 'graphql'
|
||||
import { EventType } from '../types'
|
||||
import { Event } from '../../models'
|
||||
|
||||
const args = {
|
||||
minDate: { type: GraphQLInt },
|
||||
maxDate: { type: GraphQLInt }
|
||||
}
|
||||
|
||||
const resolve = (parent, { minDate, maxDate }, context) => {
|
||||
return Event.find(
|
||||
Object.assign(
|
||||
minDate || maxDate
|
||||
? { startDatetime:
|
||||
Object.assign(
|
||||
minDate ? { $gte: minDate } : {},
|
||||
maxDate ? { $lte: maxDate } : {}
|
||||
) }
|
||||
: {}
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
const query = {
|
||||
events: {
|
||||
type: new GraphQLList(EventType),
|
||||
args,
|
||||
resolve
|
||||
}
|
||||
}
|
||||
|
||||
export default query
|
||||
@@ -0,0 +1,39 @@
|
||||
import {
|
||||
GraphQLInt,
|
||||
GraphQLList,
|
||||
GraphQLString,
|
||||
GraphQLNonNull
|
||||
} from 'graphql'
|
||||
import { EventType } from '../types'
|
||||
import { Event } from '../../models'
|
||||
|
||||
const args = {
|
||||
hostId: { type: new GraphQLNonNull(GraphQLString) },
|
||||
minDate: { type: GraphQLInt },
|
||||
maxDate: { type: GraphQLInt }
|
||||
}
|
||||
|
||||
const resolve = (parent, { hostId, minDate, maxDate }, context) => {
|
||||
return Event.find(
|
||||
Object.assign(
|
||||
{ hostId },
|
||||
minDate || maxDate
|
||||
? { startDatetime:
|
||||
Object.assign(
|
||||
minDate ? { $gte: minDate } : {},
|
||||
maxDate ? { $lte: maxDate } : {}
|
||||
) }
|
||||
: {}
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
const query = {
|
||||
eventsByHost: {
|
||||
type: new GraphQLList(EventType),
|
||||
args,
|
||||
resolve
|
||||
}
|
||||
}
|
||||
|
||||
export default query
|
||||
@@ -0,0 +1,39 @@
|
||||
import {
|
||||
GraphQLInt,
|
||||
GraphQLList,
|
||||
GraphQLString,
|
||||
GraphQLNonNull
|
||||
} from 'graphql'
|
||||
import { EventType } from '../types'
|
||||
import { Event } from '../../models'
|
||||
|
||||
const args = {
|
||||
teamId: { type: new GraphQLNonNull(GraphQLString) },
|
||||
minDate: { type: GraphQLInt },
|
||||
maxDate: { type: GraphQLInt }
|
||||
}
|
||||
|
||||
const resolve = (parent, { teamId, minDate, maxDate }, context) => {
|
||||
return Event.find(
|
||||
Object.assign(
|
||||
{ participants: { $elemMatch: { teamId } } },
|
||||
minDate || maxDate
|
||||
? { startDatetime:
|
||||
Object.assign(
|
||||
minDate ? { $gte: minDate } : {},
|
||||
maxDate ? { $lte: maxDate } : {}
|
||||
) }
|
||||
: {}
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
const query = {
|
||||
eventsByTeam: {
|
||||
type: new GraphQLList(EventType),
|
||||
args,
|
||||
resolve
|
||||
}
|
||||
}
|
||||
|
||||
export default query
|
||||
@@ -0,0 +1,21 @@
|
||||
import {
|
||||
GraphQLList
|
||||
} from 'graphql'
|
||||
import { FormulaType } from '../types'
|
||||
import { Formula } from '../../models'
|
||||
|
||||
const args = {}
|
||||
|
||||
const resolve = (parent, args, context) => {
|
||||
return Formula.find()
|
||||
}
|
||||
|
||||
const query = {
|
||||
formulas: {
|
||||
type: new GraphQLList(FormulaType),
|
||||
args,
|
||||
resolve
|
||||
}
|
||||
}
|
||||
|
||||
export default query
|
||||
@@ -0,0 +1,21 @@
|
||||
import {
|
||||
GraphQLList
|
||||
} from 'graphql'
|
||||
import { PlotterType } from '../types'
|
||||
import { Plotter } from '../../models'
|
||||
|
||||
const args = {}
|
||||
|
||||
const resolve = (parent, args, context) => {
|
||||
return Plotter.find()
|
||||
}
|
||||
|
||||
const query = {
|
||||
plotters: {
|
||||
type: new GraphQLList(PlotterType),
|
||||
args,
|
||||
resolve
|
||||
}
|
||||
}
|
||||
|
||||
export default query
|
||||
@@ -2,16 +2,20 @@ import {
|
||||
GraphQLObjectType
|
||||
} from 'graphql'
|
||||
|
||||
import CompetitionsQuery from './Competitions'
|
||||
import CompetitionsByHostQuery from './CompetitionsByHost'
|
||||
import CompetitionsByDevTeamQuery from './CompetitionsByDevTeam'
|
||||
import EventsQuery from './Events'
|
||||
import EventsByHostQuery from './EventsByHost'
|
||||
import EventsByTeamQuery from './EventsByTeam'
|
||||
import FormulasQuery from './Formulas'
|
||||
import PlottersQuery from './Plotters'
|
||||
|
||||
const RootQuery = new GraphQLObjectType({
|
||||
name: 'RootQueryType',
|
||||
fields: Object.assign(
|
||||
CompetitionsQuery,
|
||||
CompetitionsByHostQuery,
|
||||
CompetitionsByDevTeamQuery
|
||||
EventsQuery,
|
||||
EventsByHostQuery,
|
||||
EventsByTeamQuery,
|
||||
FormulasQuery,
|
||||
PlottersQuery
|
||||
)
|
||||
})
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import {
|
||||
GraphQLInt
|
||||
} from 'graphql'
|
||||
|
||||
const OtherPrizeType = new GraphQLObjectType({
|
||||
const AdditionalPrizeType = new GraphQLObjectType({
|
||||
name: 'OtherPrize',
|
||||
fields: () => ({
|
||||
condition: { type: GraphQLString },
|
||||
@@ -13,4 +13,4 @@ const OtherPrizeType = new GraphQLObjectType({
|
||||
})
|
||||
})
|
||||
|
||||
export default OtherPrizeType
|
||||
export default AdditionalPrizeType
|
||||
@@ -6,22 +6,28 @@ import {
|
||||
GraphQLID
|
||||
} from 'graphql'
|
||||
import {
|
||||
FormulaType,
|
||||
PlotterType,
|
||||
RuleType,
|
||||
ParticipantType,
|
||||
PrizeType
|
||||
} from './index'
|
||||
|
||||
const CompetitionType = new GraphQLObjectType({
|
||||
name: 'Competition',
|
||||
const EventType = new GraphQLObjectType({
|
||||
name: 'Event',
|
||||
fields: () => ({
|
||||
codeName: { type: GraphQLID },
|
||||
displayName: { type: GraphQLString },
|
||||
host: { type: GraphQLString },
|
||||
designator: { type: GraphQLID },
|
||||
name: { type: GraphQLString },
|
||||
hostId: { type: GraphQLString },
|
||||
description: { type: GraphQLString },
|
||||
startDatetime: { type: GraphQLInt },
|
||||
finishDatetime: { type: GraphQLInt },
|
||||
formula: { type: GraphQLString },
|
||||
formula: {
|
||||
type: FormulaType,
|
||||
resolve (parent, args) {
|
||||
return parent.formula
|
||||
}
|
||||
},
|
||||
plotter: {
|
||||
type: PlotterType,
|
||||
resolve (parent, args) {
|
||||
@@ -49,4 +55,4 @@ const CompetitionType = new GraphQLObjectType({
|
||||
})
|
||||
})
|
||||
|
||||
export default CompetitionType
|
||||
export default EventType
|
||||
@@ -0,0 +1,17 @@
|
||||
import {
|
||||
GraphQLObjectType,
|
||||
GraphQLString,
|
||||
GraphQLBoolean
|
||||
} from 'graphql'
|
||||
|
||||
const FormulaType = new GraphQLObjectType({
|
||||
name: 'Formula',
|
||||
fields: () => ({
|
||||
id: { type: GraphQLString },
|
||||
ownerId: { type: GraphQLString },
|
||||
isTemplate: { type: GraphQLBoolean },
|
||||
name: { type: GraphQLString }
|
||||
})
|
||||
})
|
||||
|
||||
export default FormulaType
|
||||
@@ -6,9 +6,9 @@ import {
|
||||
const ParticipantType = new GraphQLObjectType({
|
||||
name: 'Participant',
|
||||
fields: () => ({
|
||||
devTeam: { type: GraphQLString },
|
||||
bot: { type: GraphQLString },
|
||||
release: { type: GraphQLString }
|
||||
teamId: { type: GraphQLString },
|
||||
botId: { type: GraphQLString },
|
||||
releaseId: { type: GraphQLString }
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
import {
|
||||
GraphQLObjectType,
|
||||
GraphQLString
|
||||
GraphQLString,
|
||||
GraphQLBoolean
|
||||
} from 'graphql'
|
||||
|
||||
const PlotterType = new GraphQLObjectType({
|
||||
name: 'Plotter',
|
||||
fields: () => ({
|
||||
codeName: { type: GraphQLString },
|
||||
id: { type: GraphQLString },
|
||||
ownerId: { type: GraphQLString },
|
||||
isTemplate: { type: GraphQLBoolean },
|
||||
name: { type: GraphQLString },
|
||||
host: { type: GraphQLString },
|
||||
repo: { type: GraphQLString },
|
||||
moduleName: { type: GraphQLString }
|
||||
|
||||
@@ -3,17 +3,17 @@ import {
|
||||
GraphQLList,
|
||||
GraphQLInt
|
||||
} from 'graphql'
|
||||
import { OtherPrizeType } from './index'
|
||||
import { AdditionalPrizeType } from './index'
|
||||
|
||||
const PrizeType = new GraphQLObjectType({
|
||||
name: 'Prize',
|
||||
fields: () => ({
|
||||
position: { type: GraphQLInt },
|
||||
algoPrize: { type: GraphQLInt },
|
||||
otherPrizes: {
|
||||
type: new GraphQLList(OtherPrizeType),
|
||||
rank: { type: GraphQLInt },
|
||||
amount: { type: GraphQLInt },
|
||||
additional: {
|
||||
type: new GraphQLList(AdditionalPrizeType),
|
||||
resolve (parent, args) {
|
||||
return parent.otherPrizes
|
||||
return parent.additional
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
const RuleType = new GraphQLObjectType({
|
||||
name: 'Rule',
|
||||
fields: () => ({
|
||||
number: { type: GraphQLInt },
|
||||
position: { type: GraphQLInt },
|
||||
title: { type: GraphQLString },
|
||||
description: { type: GraphQLString }
|
||||
})
|
||||
|
||||
@@ -1,15 +1,17 @@
|
||||
import PlotterType from './Plotter'
|
||||
import RuleType from './Rule'
|
||||
import ParticipantType from './Participant'
|
||||
import OtherPrizeType from './OtherPrize'
|
||||
import AdditionalPrizeType from './AdditionalPrize'
|
||||
import PrizeType from './Prize'
|
||||
import CompetitionType from './Competition'
|
||||
import FormulaType from './Formula'
|
||||
import EventType from './Event'
|
||||
|
||||
export {
|
||||
PlotterType,
|
||||
RuleType,
|
||||
ParticipantType,
|
||||
OtherPrizeType,
|
||||
AdditionalPrizeType,
|
||||
PrizeType,
|
||||
CompetitionType
|
||||
FormulaType,
|
||||
EventType
|
||||
}
|
||||
Reference in new issue
Block a user