Merge Complete
This commit is contained in:
1 parent
482ef7a81a
commit
dabe23d505
6483 files changed
No files matched your search
@@ -0,0 +1,35 @@
|
||||
import {
|
||||
GraphQLNonNull,
|
||||
GraphQLString,
|
||||
} from 'graphql';
|
||||
import { DatabaseError } from '../../errors';
|
||||
import { TradingSystemType } from '../types';
|
||||
import { TradingSystem } from '../../models';
|
||||
|
||||
const args = {
|
||||
id: { type: new GraphQLNonNull(GraphQLString) },
|
||||
};
|
||||
|
||||
const resolve = (parent, { id }) => new Promise((res, rej) => {
|
||||
TradingSystem.findOne({ _id: id }).exec((err, tradingSystem) => {
|
||||
if (err) {
|
||||
rej(err);
|
||||
return;
|
||||
}
|
||||
if (!tradingSystem) {
|
||||
rej(new DatabaseError('None of the tradingSystem are linked to that id'));
|
||||
return;
|
||||
}
|
||||
res(tradingSystem);
|
||||
});
|
||||
});
|
||||
|
||||
const query = {
|
||||
tradingSystemById: {
|
||||
type: TradingSystemType,
|
||||
args,
|
||||
resolve,
|
||||
},
|
||||
};
|
||||
|
||||
export default query;
|
||||
Reference in new issue
Block a user