chore: Expose connection with step type instead of only connectionId
This commit is contained in:

committed by
Ömer Faruk Aydın

parent
11bdbf1727
commit
a58411ee99
@@ -8,11 +8,9 @@ type Params = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const getFlowResolver = async (params: Params, req: RequestWithCurrentUser) => {
|
const getFlowResolver = async (params: Params, req: RequestWithCurrentUser) => {
|
||||||
const flowParams = { user_id: req.currentUser.id, id: params.id }
|
|
||||||
|
|
||||||
const flow = await Flow.query()
|
const flow = await Flow.query()
|
||||||
.withGraphFetched('steps')
|
.withGraphJoined('[steps.[connection]]')
|
||||||
.findOne(flowParams)
|
.findOne({'flows.user_id': req.currentUser.id, 'flows.id': params.id})
|
||||||
.throwIfNotFound();
|
.throwIfNotFound();
|
||||||
|
|
||||||
return flow;
|
return flow;
|
||||||
|
@@ -5,7 +5,8 @@ import flowType from '../types/flow';
|
|||||||
|
|
||||||
const getFlowsResolver = async (req: RequestWithCurrentUser) => {
|
const getFlowsResolver = async (req: RequestWithCurrentUser) => {
|
||||||
const flows = await Flow.query()
|
const flows = await Flow.query()
|
||||||
.where({ user_id: req.currentUser.id});
|
.withGraphJoined('[steps.[connection]]')
|
||||||
|
.where({'flows.user_id': req.currentUser.id});
|
||||||
|
|
||||||
return flows;
|
return flows;
|
||||||
}
|
}
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
import { GraphQLObjectType, GraphQLString, GraphQLNonNull, GraphQLEnumType, GraphQLInt } from 'graphql';
|
import { GraphQLObjectType, GraphQLString, GraphQLNonNull, GraphQLEnumType, GraphQLInt } from 'graphql';
|
||||||
|
import ConnectionType from './connection';
|
||||||
|
|
||||||
const stepType = new GraphQLObjectType({
|
const stepType = new GraphQLObjectType({
|
||||||
name: 'Step',
|
name: 'Step',
|
||||||
@@ -15,7 +16,7 @@ const stepType = new GraphQLObjectType({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
connectionId: { type: GraphQLNonNull(GraphQLInt) }
|
connection: { type: ConnectionType }
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
import Base from './base';
|
import Base from './base';
|
||||||
import Flow from './flow';
|
import Flow from './flow';
|
||||||
|
import Connection from './connection';
|
||||||
|
|
||||||
enum StepEnumType {
|
enum StepEnumType {
|
||||||
'trigger',
|
'trigger',
|
||||||
@@ -37,9 +38,17 @@ class Step extends Base {
|
|||||||
relation: Base.BelongsToOneRelation,
|
relation: Base.BelongsToOneRelation,
|
||||||
modelClass: Flow,
|
modelClass: Flow,
|
||||||
join: {
|
join: {
|
||||||
from: 'step.flow_id',
|
from: 'steps.flow_id',
|
||||||
to: 'flows.id',
|
to: 'flows.id',
|
||||||
},
|
},
|
||||||
|
},
|
||||||
|
connection: {
|
||||||
|
relation: Base.HasOneRelation,
|
||||||
|
modelClass: Connection,
|
||||||
|
join: {
|
||||||
|
from: 'steps.connection_id',
|
||||||
|
to: 'connections.id'
|
||||||
|
},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user