yet a bit more refactoring
This commit is contained in:
1 parent
eeda497f97
commit
676e7619d8
6 files changed
+24
-24
No files matched your search
@@ -12,13 +12,13 @@ const args = {
|
||||
description: { type: new GraphQLNonNull(GraphQLString) }
|
||||
}
|
||||
|
||||
const resolve = (parent, args, context) => {
|
||||
const resolve = (parent, { codeName, title, description }, context) => {
|
||||
// let authIdOnSession = context.user.sub
|
||||
return new Promise((resolve, reject) => {
|
||||
Competition.findOne({ codeName: args.codeName }).exec((err, competition) => {
|
||||
Competition.findOne({ codeName }).exec((err, competition) => {
|
||||
if (err) reject(err)
|
||||
else {
|
||||
if (competition.rules.some(rule => rule.title === args.title)) {
|
||||
if (competition.rules.some(rule => rule.title === title)) {
|
||||
// need to add an error message here TODO
|
||||
resolve(competition)
|
||||
} else {
|
||||
@@ -28,8 +28,8 @@ const resolve = (parent, args, context) => {
|
||||
}
|
||||
competition.rules.push({
|
||||
number,
|
||||
title: args.title,
|
||||
description: args.description
|
||||
title,
|
||||
description
|
||||
})
|
||||
competition.save((err) => {
|
||||
if (err) reject(err)
|
||||
|
||||
Reference in new issue
Block a user