From 8f0c6e2e3723e6419b01f712fab814188d9c70bb Mon Sep 17 00:00:00 2001 From: Unknown Date: Sat, 16 Mar 2019 13:07:35 +0100 Subject: [PATCH] Setting up the seven monolithics types for output types --- src/schema/types/SubStrategy.js | 65 ++++++-------- src/schema/types/TheSevenMonolitics.js | 113 +++++++++++++++++++++++++ src/schema/types/index.js | 16 ++++ 3 files changed, 157 insertions(+), 37 deletions(-) create mode 100644 src/schema/types/TheSevenMonolitics.js diff --git a/src/schema/types/SubStrategy.js b/src/schema/types/SubStrategy.js index fc22691ca..5d34e8caa 100644 --- a/src/schema/types/SubStrategy.js +++ b/src/schema/types/SubStrategy.js @@ -4,8 +4,13 @@ import { GraphQLList, } from 'graphql'; import { - SituationType, - PhaseType, + EntryPointType, + ExitPointType, + SellPointType, + BuyPointType, + StopLossType, + BuyOrderType, + SellOrderType, } from './index'; const Type = new GraphQLObjectType({ @@ -14,59 +19,45 @@ const Type = new GraphQLObjectType({ fields: () => ({ name: { type: GraphQLString }, entryPoint: { - situations: { - type: new GraphQLList(SituationType), - resolve(parent) { - return parent.situations; - }, + type: new GraphQLList(EntryPointType), + resolve(parent) { + return parent.entryPoint; }, }, exitPoint: { - situations: { - type: new GraphQLList(SituationType), - resolve(parent) { - return parent.situations; - }, + type: new GraphQLList(ExitPointType), + resolve(parent) { + return parent.exitPoint; }, }, sellPoint: { - situations: { - type: new GraphQLList(SituationType), - resolve(parent) { - return parent.situations; - }, + type: new GraphQLList(SellPointType), + resolve(parent) { + return parent.sellPoint; }, }, buyPoint: { - situations: { - type: new GraphQLList(SituationType), - resolve(parent) { - return parent.situations; - }, + type: new GraphQLList(BuyPointType), + resolve(parent) { + return parent.buyPoint; }, }, stopLoss: { - phases: { - type: new GraphQLList(PhaseType), - resolve(parent) { - return parent.phases; - }, + type: new GraphQLList(StopLossType), + resolve(parent) { + return parent.stopLoss; }, }, buyOrder: { - phases: { - type: new GraphQLList(PhaseType), - resolve(parent) { - return parent.phases; - }, + type: new GraphQLList(BuyOrderType), + resolve(parent) { + return parent.buyOrder; }, }, sellOrder: { - phases: { - type: new GraphQLList(PhaseType), - resolve(parent) { - return parent.phases; - }, + type: new GraphQLList(SellOrderType), + resolve(parent) { + return parent.sellOrder; }, }, }), diff --git a/src/schema/types/TheSevenMonolitics.js b/src/schema/types/TheSevenMonolitics.js new file mode 100644 index 000000000..6a261224b --- /dev/null +++ b/src/schema/types/TheSevenMonolitics.js @@ -0,0 +1,113 @@ +import { + GraphQLObjectType, + GraphQLList, +} from 'graphql'; +import { + SituationType, + PhaseType, +} from './index'; + +// ConditionBased + +const EntryPointType = new GraphQLObjectType({ + name: 'EntryPoint', + description: 'EntryPoint definition', + fields: () => ({ + situations: { + type: new GraphQLList(SituationType), + resolve(parent) { + return parent.situations; + }, + }, + }), +}); + +const ExitPointType = new GraphQLObjectType({ + name: 'ExitPoint', + description: 'ExitPoint definition', + fields: () => ({ + situations: { + type: new GraphQLList(SituationType), + resolve(parent) { + return parent.situations; + }, + }, + }), +}); + +const SellPointType = new GraphQLObjectType({ + name: 'SellPoint', + description: 'SellPoint definition', + fields: () => ({ + situations: { + type: new GraphQLList(SituationType), + resolve(parent) { + return parent.situations; + }, + }, + }), +}); + +const BuyPointType = new GraphQLObjectType({ + name: 'BuyPoint', + description: 'BuyPoint definition', + fields: () => ({ + situations: { + type: new GraphQLList(SituationType), + resolve(parent) { + return parent.situations; + }, + }, + }), +}); + +// PhaseBased + +const StopLossType = new GraphQLObjectType({ + name: 'StopLoss', + description: 'StopLoss definition', + fields: () => ({ + phases: { + type: new GraphQLList(PhaseType), + resolve(parent) { + return parent.phases; + }, + }, + }), +}); + +const BuyOrderType = new GraphQLObjectType({ + name: 'BuyOrder', + description: 'BuyOrder definition', + fields: () => ({ + phases: { + type: new GraphQLList(PhaseType), + resolve(parent) { + return parent.phases; + }, + }, + }), +}); + +const SellOrderType = new GraphQLObjectType({ + name: 'SellOrder', + description: 'SellOrder definition', + fields: () => ({ + phases: { + type: new GraphQLList(PhaseType), + resolve(parent) { + return parent.phases; + }, + }, + }), +}); + +export { + EntryPointType, + ExitPointType, + SellPointType, + BuyPointType, + StopLossType, + BuyOrderType, + SellOrderType, +}; diff --git a/src/schema/types/index.js b/src/schema/types/index.js index d2715104d..87d2fface 100644 --- a/src/schema/types/index.js +++ b/src/schema/types/index.js @@ -3,6 +3,15 @@ import SubStrategyType from './SubStrategy'; import ConditionType from './Condition'; import SituationType from './Situation'; import PhaseType from './Phase'; +import { + EntryPointType, + ExitPointType, + SellPointType, + BuyPointType, + StopLossType, + BuyOrderType, + SellOrderType, +} from './TheSevenMonolitics'; export { StrategyType, @@ -10,4 +19,11 @@ export { ConditionType, SituationType, PhaseType, + EntryPointType, + ExitPointType, + SellPointType, + BuyPointType, + StopLossType, + BuyOrderType, + SellOrderType, };