defining strategy output graphql types
This commit is contained in:
1 parent
7ec9ac9bde
commit
afb04b914b
11 files changed
+175
-120
No files matched your search
@@ -0,0 +1,15 @@
|
||||
import {
|
||||
GraphQLObjectType,
|
||||
GraphQLString,
|
||||
} from 'graphql';
|
||||
|
||||
const ConditionType = new GraphQLObjectType({
|
||||
name: 'Condition',
|
||||
description: 'Condition definition',
|
||||
fields: () => ({
|
||||
name: { type: GraphQLString },
|
||||
code: { type: GraphQLString },
|
||||
}),
|
||||
});
|
||||
|
||||
export default ConditionType;
|
||||
@@ -1,43 +0,0 @@
|
||||
import {
|
||||
GraphQLObjectType,
|
||||
GraphQLString,
|
||||
GraphQLList,
|
||||
GraphQLID,
|
||||
} from 'graphql';
|
||||
import {
|
||||
FormulaType,
|
||||
PlotterType,
|
||||
PrizeType,
|
||||
} from './index';
|
||||
import EventStateEnumType from './enum/EventState';
|
||||
|
||||
const EventType = new GraphQLObjectType({
|
||||
name: 'Event',
|
||||
description: 'Everything you need to know about an event',
|
||||
fields: () => ({
|
||||
id: { type: GraphQLID },
|
||||
state: { type: EventStateEnumType },
|
||||
name: { type: GraphQLString },
|
||||
hostId: { type: GraphQLString },
|
||||
formula: {
|
||||
type: FormulaType,
|
||||
resolve(parent) {
|
||||
return parent.formulaId;
|
||||
},
|
||||
},
|
||||
plotter: {
|
||||
type: PlotterType,
|
||||
resolve(parent) {
|
||||
return parent.plotterId;
|
||||
},
|
||||
},
|
||||
prizes: {
|
||||
type: new GraphQLList(PrizeType),
|
||||
resolve(parent) {
|
||||
return parent.prizes;
|
||||
},
|
||||
},
|
||||
}),
|
||||
});
|
||||
|
||||
export default EventType;
|
||||
@@ -1,15 +0,0 @@
|
||||
import {
|
||||
GraphQLObjectType,
|
||||
GraphQLString,
|
||||
} from 'graphql';
|
||||
|
||||
const FormulaType = new GraphQLObjectType({
|
||||
name: 'Formula',
|
||||
description: 'For now it\'s simplay a named field',
|
||||
fields: () => ({
|
||||
id: { type: GraphQLString },
|
||||
name: { type: GraphQLString },
|
||||
}),
|
||||
});
|
||||
|
||||
export default FormulaType;
|
||||
@@ -0,0 +1,25 @@
|
||||
import {
|
||||
GraphQLObjectType,
|
||||
GraphQLString,
|
||||
GraphQLList,
|
||||
} from 'graphql';
|
||||
import {
|
||||
SituationType,
|
||||
} from './index';
|
||||
|
||||
const PhaseType = new GraphQLObjectType({
|
||||
name: 'Phase',
|
||||
code: 'Phase',
|
||||
description: 'Phase definition',
|
||||
fields: () => ({
|
||||
name: { type: GraphQLString },
|
||||
situations: {
|
||||
type: new GraphQLList(SituationType),
|
||||
resolve(parent) {
|
||||
return parent.situations;
|
||||
},
|
||||
},
|
||||
}),
|
||||
});
|
||||
|
||||
export default PhaseType;
|
||||
@@ -1,15 +0,0 @@
|
||||
import {
|
||||
GraphQLObjectType,
|
||||
GraphQLString,
|
||||
} from 'graphql';
|
||||
|
||||
const PlotterType = new GraphQLObjectType({
|
||||
name: 'Plotter',
|
||||
description: 'Will soon change in order to use contained plotter objects',
|
||||
fields: () => ({
|
||||
id: { type: GraphQLString },
|
||||
name: { type: GraphQLString },
|
||||
}),
|
||||
});
|
||||
|
||||
export default PlotterType;
|
||||
@@ -1,23 +0,0 @@
|
||||
import {
|
||||
GraphQLObjectType,
|
||||
GraphQLList,
|
||||
GraphQLString,
|
||||
GraphQLNonNull,
|
||||
} from 'graphql';
|
||||
import { SubPrizeType } from './index';
|
||||
|
||||
const PrizeType = new GraphQLObjectType({
|
||||
name: 'Prize',
|
||||
description: 'Prize, by default in algos',
|
||||
fields: () => ({
|
||||
rank: { type: new GraphQLNonNull(GraphQLString) },
|
||||
subPrize: {
|
||||
type: new GraphQLList(SubPrizeType),
|
||||
resolve(parent) {
|
||||
return parent.subPrize;
|
||||
},
|
||||
},
|
||||
}),
|
||||
});
|
||||
|
||||
export default PrizeType;
|
||||
@@ -0,0 +1,24 @@
|
||||
import {
|
||||
GraphQLObjectType,
|
||||
GraphQLString,
|
||||
GraphQLList,
|
||||
} from 'graphql';
|
||||
import {
|
||||
ConditionType,
|
||||
} from './index';
|
||||
|
||||
const SituationType = new GraphQLObjectType({
|
||||
name: 'Situation',
|
||||
description: 'Situation definition',
|
||||
fields: () => ({
|
||||
name: { type: GraphQLString },
|
||||
conditions: {
|
||||
type: new GraphQLList(ConditionType),
|
||||
resolve(parent) {
|
||||
return parent.conditions;
|
||||
},
|
||||
},
|
||||
}),
|
||||
});
|
||||
|
||||
export default SituationType;
|
||||
@@ -0,0 +1,26 @@
|
||||
import {
|
||||
GraphQLObjectType,
|
||||
GraphQLString,
|
||||
GraphQLList,
|
||||
GraphQLID,
|
||||
} from 'graphql';
|
||||
import {
|
||||
SubStrategyType,
|
||||
} from './index';
|
||||
|
||||
const EventType = new GraphQLObjectType({
|
||||
name: 'Event',
|
||||
description: 'Everything you need to know about an event',
|
||||
fields: () => ({
|
||||
id: { type: GraphQLID },
|
||||
fbId: { type: GraphQLString },
|
||||
subStrategies: {
|
||||
type: new GraphQLList(SubStrategyType),
|
||||
resolve(parent) {
|
||||
return parent.subStrategies;
|
||||
},
|
||||
},
|
||||
}),
|
||||
});
|
||||
|
||||
export default EventType;
|
||||
@@ -1,14 +0,0 @@
|
||||
import {
|
||||
GraphQLObjectType,
|
||||
GraphQLString,
|
||||
} from 'graphql';
|
||||
|
||||
const SubPrizeType = new GraphQLObjectType({
|
||||
name: 'SubPrize',
|
||||
description: 'Prize',
|
||||
fields: () => ({
|
||||
condition: { type: GraphQLString },
|
||||
}),
|
||||
});
|
||||
|
||||
export default SubPrizeType;
|
||||
@@ -0,0 +1,75 @@
|
||||
import {
|
||||
GraphQLObjectType,
|
||||
GraphQLString,
|
||||
GraphQLList,
|
||||
} from 'graphql';
|
||||
import {
|
||||
SituationType,
|
||||
PhaseType,
|
||||
} from './index';
|
||||
|
||||
const SubStrategyType = new GraphQLObjectType({
|
||||
name: 'SubStrategy',
|
||||
description: 'SubStrategy composing a strategy',
|
||||
fields: () => ({
|
||||
name: { type: GraphQLString },
|
||||
entryPoint: {
|
||||
situations: {
|
||||
type: new GraphQLList(SituationType),
|
||||
resolve(parent) {
|
||||
return parent.situations;
|
||||
},
|
||||
},
|
||||
},
|
||||
exitPoint: {
|
||||
situations: {
|
||||
type: new GraphQLList(SituationType),
|
||||
resolve(parent) {
|
||||
return parent.situations;
|
||||
},
|
||||
},
|
||||
},
|
||||
sellPoint: {
|
||||
situations: {
|
||||
type: new GraphQLList(SituationType),
|
||||
resolve(parent) {
|
||||
return parent.situations;
|
||||
},
|
||||
},
|
||||
},
|
||||
buyPoint: {
|
||||
situations: {
|
||||
type: new GraphQLList(SituationType),
|
||||
resolve(parent) {
|
||||
return parent.situations;
|
||||
},
|
||||
},
|
||||
},
|
||||
stopLoss: {
|
||||
phases: {
|
||||
type: new GraphQLList(PhaseType),
|
||||
resolve(parent) {
|
||||
return parent.phases;
|
||||
},
|
||||
},
|
||||
},
|
||||
buyOrder: {
|
||||
phases: {
|
||||
type: new GraphQLList(PhaseType),
|
||||
resolve(parent) {
|
||||
return parent.phases;
|
||||
},
|
||||
},
|
||||
},
|
||||
sellOrder: {
|
||||
phases: {
|
||||
type: new GraphQLList(PhaseType),
|
||||
resolve(parent) {
|
||||
return parent.phases;
|
||||
},
|
||||
},
|
||||
},
|
||||
}),
|
||||
});
|
||||
|
||||
export default SubStrategyType;
|
||||
+10
-10
@@ -1,13 +1,13 @@
|
||||
import PlotterType from './Plotter';
|
||||
import SubPrizeType from './SubPrize';
|
||||
import PrizeType from './Prize';
|
||||
import FormulaType from './Formula';
|
||||
import EventType from './Event';
|
||||
import StrategyType from './Strategy';
|
||||
import SubStrategyType from './SubStrategy';
|
||||
import ConditionType from './Condition';
|
||||
import SituationType from './Situation';
|
||||
import PhaseType from './Phase';
|
||||
|
||||
export {
|
||||
PlotterType,
|
||||
SubPrizeType,
|
||||
PrizeType,
|
||||
FormulaType,
|
||||
EventType,
|
||||
StrategyType,
|
||||
SubStrategyType,
|
||||
ConditionType,
|
||||
SituationType,
|
||||
PhaseType,
|
||||
};
|
||||
Reference in new issue
Block a user