Went from fbId to fbSlug
This commit is contained in:
1 parent
58c2bf7080
commit
a7cb752f1e
4 files changed
+9
-9
No files matched your search
@@ -2,7 +2,7 @@ import mongoose, { Schema } from 'mongoose';
|
||||
|
||||
const strategySchema = new Schema(
|
||||
{
|
||||
fbId: {
|
||||
fbSlug: {
|
||||
type: String,
|
||||
required: true,
|
||||
unique: true,
|
||||
|
||||
@@ -7,12 +7,12 @@ import { Strategy } from '../../models';
|
||||
import { StrategyInputType } from '../types/input';
|
||||
|
||||
export const args = {
|
||||
fbId: { type: new GraphQLNonNull(GraphQLString) },
|
||||
fbSlug: { type: new GraphQLNonNull(GraphQLString) },
|
||||
strategy: { type: StrategyInputType },
|
||||
};
|
||||
|
||||
const resolve = (parent, { fbId, strategy }) => {
|
||||
strategy.fbId = fbId;
|
||||
const resolve = (parent, { fbSlug, strategy }) => {
|
||||
strategy.fbSlug = fbSlug;
|
||||
const newStrategy = new Strategy(strategy);
|
||||
|
||||
return new Promise((res, rej) => {
|
||||
|
||||
@@ -7,17 +7,17 @@ import { StrategyType } from '../types';
|
||||
import { Strategy } from '../../models';
|
||||
|
||||
const args = {
|
||||
fbId: { type: new GraphQLNonNull(GraphQLID) },
|
||||
fbSlug: { type: new GraphQLNonNull(GraphQLID) },
|
||||
};
|
||||
|
||||
const resolve = (parent, { fbId }) => new Promise((res, rej) => {
|
||||
Strategy.findOne({ fbId }).exec((err, strategy) => {
|
||||
const resolve = (parent, { fbSlug }) => new Promise((res, rej) => {
|
||||
Strategy.findOne({ fbSlug }).exec((err, strategy) => {
|
||||
if (err) {
|
||||
rej(err);
|
||||
return;
|
||||
}
|
||||
if (!strategy) {
|
||||
rej(new DatabaseError('None of the strategy are linked to that fbId'));
|
||||
rej(new DatabaseError('None of the strategy are linked to that fbSlug'));
|
||||
return;
|
||||
}
|
||||
res(strategy);
|
||||
|
||||
@@ -13,7 +13,7 @@ const Type = new GraphQLObjectType({
|
||||
description: 'Everything you need to know about a strategy',
|
||||
fields: () => ({
|
||||
id: { type: GraphQLID },
|
||||
fbId: { type: GraphQLString },
|
||||
fbSlug: { type: GraphQLString },
|
||||
subStrategies: {
|
||||
type: new GraphQLList(SubStrategyType),
|
||||
resolve(parent) {
|
||||
|
||||
Reference in new issue
Block a user