Strategizer Server moved to old repos
This commit is contained in:
1 parent
dc50cfa303
commit
b91b7a20dd
36 files changed
No files matched your search
@@ -0,0 +1,42 @@
|
||||
import {
|
||||
GraphQLNonNull,
|
||||
GraphQLString,
|
||||
} from 'graphql';
|
||||
import { TradingSystemType } from '../types';
|
||||
import { TradingSystem } from '../../models';
|
||||
import { TradingSystemInputType } from '../types/input';
|
||||
import defaultTradingSystem from '../../templates/tradingSystemTemplate';
|
||||
|
||||
export const args = {
|
||||
fbSlug: { type: new GraphQLNonNull(GraphQLString) },
|
||||
tradingSystem: { type: TradingSystemInputType },
|
||||
};
|
||||
|
||||
const resolve = (parent, { fbSlug, tradingSystem }) => {
|
||||
if (tradingSystem === undefined) {
|
||||
tradingSystem = defaultTradingSystem;
|
||||
}
|
||||
tradingSystem.fbSlug = fbSlug;
|
||||
tradingSystem.history = [];
|
||||
const newTradingSystem = new TradingSystem(tradingSystem);
|
||||
|
||||
return new Promise((res, rej) => {
|
||||
newTradingSystem.save((err) => {
|
||||
if (err) {
|
||||
rej(err);
|
||||
return;
|
||||
}
|
||||
res(newTradingSystem);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
const mutation = {
|
||||
createTradingSystem: {
|
||||
type: TradingSystemType,
|
||||
args,
|
||||
resolve,
|
||||
},
|
||||
};
|
||||
|
||||
export default mutation;
|
||||
Reference in new issue
Block a user