chore: Use string IDs instead of integer ones
This commit is contained in:

committed by
Ömer Faruk Aydın

parent
86d5cceec7
commit
c6e2b94128
@@ -1,10 +1,9 @@
|
||||
import { GraphQLNonNull, GraphQLInt } from 'graphql';
|
||||
import Connection from '../../models/connection';
|
||||
import { GraphQLNonNull, GraphQLString } from 'graphql';
|
||||
import authLinkType from '../types/auth-link';
|
||||
import RequestWithCurrentUser from '../../types/express/request-with-current-user';
|
||||
|
||||
type Params = {
|
||||
id: number;
|
||||
id: string;
|
||||
};
|
||||
|
||||
const createAuthDataResolver = async (
|
||||
@@ -40,7 +39,7 @@ const createAuthDataResolver = async (
|
||||
const createAuthData = {
|
||||
type: authLinkType,
|
||||
args: {
|
||||
id: { type: GraphQLNonNull(GraphQLInt) },
|
||||
id: { type: GraphQLNonNull(GraphQLString) },
|
||||
},
|
||||
resolve: (_: any, params: Params, req: RequestWithCurrentUser) =>
|
||||
createAuthDataResolver(params, req),
|
||||
|
@@ -3,7 +3,7 @@ import flowType from '../types/flow';
|
||||
import RequestWithCurrentUser from '../../types/express/request-with-current-user';
|
||||
|
||||
const createFlowResolver = async (req: RequestWithCurrentUser) => {
|
||||
const flow = await req.currentUser.$relatedQuery('flows').insert();
|
||||
const flow = await req.currentUser.$relatedQuery('flows').insert({});
|
||||
|
||||
await Step.query().insert({
|
||||
flowId: flow.id,
|
||||
|
@@ -1,8 +1,8 @@
|
||||
import { GraphQLInt, GraphQLNonNull, GraphQLBoolean } from 'graphql';
|
||||
import { GraphQLString, GraphQLNonNull, GraphQLBoolean } from 'graphql';
|
||||
import RequestWithCurrentUser from '../../types/express/request-with-current-user';
|
||||
|
||||
type Params = {
|
||||
id: number;
|
||||
id: string;
|
||||
data: object;
|
||||
};
|
||||
const deleteConnectionResolver = async (
|
||||
@@ -23,7 +23,7 @@ const deleteConnectionResolver = async (
|
||||
const deleteConnection = {
|
||||
type: GraphQLBoolean,
|
||||
args: {
|
||||
id: { type: GraphQLNonNull(GraphQLInt) },
|
||||
id: { type: GraphQLNonNull(GraphQLString) },
|
||||
},
|
||||
resolve: (_: any, params: Params, req: RequestWithCurrentUser) =>
|
||||
deleteConnectionResolver(params, req),
|
||||
|
@@ -1,9 +1,9 @@
|
||||
import { GraphQLInt, GraphQLNonNull, GraphQLBoolean } from 'graphql';
|
||||
import { GraphQLString, GraphQLNonNull, GraphQLBoolean } from 'graphql';
|
||||
import Step from '../../models/step';
|
||||
import RequestWithCurrentUser from '../../types/express/request-with-current-user';
|
||||
|
||||
type Params = {
|
||||
id: number;
|
||||
id: string;
|
||||
};
|
||||
|
||||
const deleteStepResolver = async (
|
||||
@@ -24,7 +24,7 @@ const deleteStepResolver = async (
|
||||
const deleteStep = {
|
||||
type: GraphQLBoolean,
|
||||
args: {
|
||||
id: { type: GraphQLNonNull(GraphQLInt) },
|
||||
id: { type: GraphQLNonNull(GraphQLString) },
|
||||
},
|
||||
resolve: (_: any, params: Params, req: RequestWithCurrentUser) =>
|
||||
deleteStepResolver(params, req),
|
||||
|
@@ -1,34 +1,38 @@
|
||||
import { GraphQLInt, GraphQLNonNull } from 'graphql';
|
||||
import { GraphQLString, GraphQLNonNull } from 'graphql';
|
||||
import Connection from '../../models/connection';
|
||||
import Step from '../../models/step';
|
||||
import stepType from '../types/step';
|
||||
|
||||
type Params = {
|
||||
id: number,
|
||||
data: Record<string, unknown>
|
||||
}
|
||||
id: string;
|
||||
data: Record<string, unknown>;
|
||||
};
|
||||
const executeStepResolver = async (params: Params): Promise<any> => {
|
||||
const step = await Step.query().findOne({
|
||||
id: params.id
|
||||
}).throwIfNotFound();
|
||||
const step = await Step.query()
|
||||
.findOne({
|
||||
id: params.id,
|
||||
})
|
||||
.throwIfNotFound();
|
||||
|
||||
const connection = await Connection.query().findOne({
|
||||
id: step.connectionId
|
||||
}).throwIfNotFound();
|
||||
const connection = await Connection.query()
|
||||
.findOne({
|
||||
id: step.connectionId,
|
||||
})
|
||||
.throwIfNotFound();
|
||||
|
||||
const appClass = (await import(`../../apps/${step.appKey}`)).default;
|
||||
const appInstance = new appClass(connection.data);
|
||||
await appInstance.triggers[step.key].run();
|
||||
|
||||
return step;
|
||||
}
|
||||
};
|
||||
|
||||
const executeStep = {
|
||||
type: stepType,
|
||||
args: {
|
||||
id: { type: GraphQLNonNull(GraphQLInt) }
|
||||
id: { type: GraphQLNonNull(GraphQLString) },
|
||||
},
|
||||
resolve: (_: any, params: Params) => executeStepResolver(params)
|
||||
resolve: (_: any, params: Params) => executeStepResolver(params),
|
||||
};
|
||||
|
||||
export default executeStep;
|
||||
|
@@ -1,9 +1,9 @@
|
||||
import { GraphQLInt, GraphQLNonNull } from 'graphql';
|
||||
import { GraphQLString, GraphQLNonNull } from 'graphql';
|
||||
import connectionType from '../types/connection';
|
||||
import RequestWithCurrentUser from '../../types/express/request-with-current-user';
|
||||
|
||||
type Params = {
|
||||
id: number;
|
||||
id: string;
|
||||
};
|
||||
|
||||
const resetConnectionResolver = async (
|
||||
@@ -27,7 +27,7 @@ const resetConnectionResolver = async (
|
||||
const resetConnection = {
|
||||
type: connectionType,
|
||||
args: {
|
||||
id: { type: GraphQLNonNull(GraphQLInt) },
|
||||
id: { type: GraphQLNonNull(GraphQLString) },
|
||||
},
|
||||
resolve: (_: any, params: Params, req: RequestWithCurrentUser) =>
|
||||
resetConnectionResolver(params, req),
|
||||
|
@@ -1,12 +1,13 @@
|
||||
import { GraphQLInt, GraphQLNonNull } from 'graphql';
|
||||
import { GraphQLString, GraphQLNonNull } from 'graphql';
|
||||
import { GraphQLJSONObject } from 'graphql-type-json';
|
||||
import connectionType from '../types/connection';
|
||||
import RequestWithCurrentUser from '../../types/express/request-with-current-user';
|
||||
|
||||
type Params = {
|
||||
id: number;
|
||||
id: string;
|
||||
data: object;
|
||||
};
|
||||
|
||||
const updateConnectionResolver = async (
|
||||
params: Params,
|
||||
req: RequestWithCurrentUser
|
||||
@@ -31,7 +32,7 @@ const updateConnectionResolver = async (
|
||||
const updateConnection = {
|
||||
type: connectionType,
|
||||
args: {
|
||||
id: { type: GraphQLNonNull(GraphQLInt) },
|
||||
id: { type: GraphQLNonNull(GraphQLString) },
|
||||
data: { type: GraphQLNonNull(GraphQLJSONObject) },
|
||||
},
|
||||
resolve: (_: any, params: Params, req: RequestWithCurrentUser) =>
|
||||
|
@@ -1,11 +1,12 @@
|
||||
import { GraphQLInt, GraphQLString, GraphQLNonNull } from 'graphql';
|
||||
import { GraphQLString, GraphQLNonNull } from 'graphql';
|
||||
import flowType from '../types/flow';
|
||||
import RequestWithCurrentUser from '../../types/express/request-with-current-user';
|
||||
|
||||
type Params = {
|
||||
id: number;
|
||||
id: string;
|
||||
name: string;
|
||||
};
|
||||
|
||||
const updateFlowResolver = async (
|
||||
params: Params,
|
||||
req: RequestWithCurrentUser
|
||||
@@ -28,7 +29,7 @@ const updateFlowResolver = async (
|
||||
const updateFlow = {
|
||||
type: flowType,
|
||||
args: {
|
||||
id: { type: GraphQLNonNull(GraphQLInt) },
|
||||
id: { type: GraphQLNonNull(GraphQLString) },
|
||||
name: { type: GraphQLNonNull(GraphQLString) },
|
||||
},
|
||||
resolve: (_: any, params: Params, req: RequestWithCurrentUser) =>
|
||||
|
@@ -5,15 +5,15 @@ import RequestWithCurrentUser from '../../types/express/request-with-current-use
|
||||
|
||||
type Params = {
|
||||
input: {
|
||||
id: number;
|
||||
id: string;
|
||||
key: string;
|
||||
appKey: string;
|
||||
parameters: string;
|
||||
flow: {
|
||||
id: number;
|
||||
id: string;
|
||||
};
|
||||
connection: {
|
||||
id: number;
|
||||
id: string;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
@@ -1,10 +1,11 @@
|
||||
import { GraphQLInt, GraphQLNonNull } from 'graphql';
|
||||
import { GraphQLString, GraphQLNonNull } from 'graphql';
|
||||
import connectionType from '../types/connection';
|
||||
import RequestWithCurrentUser from '../../types/express/request-with-current-user';
|
||||
|
||||
type Params = {
|
||||
id: number;
|
||||
id: string;
|
||||
};
|
||||
|
||||
const verifyConnectionResolver = async (
|
||||
params: Params,
|
||||
req: RequestWithCurrentUser
|
||||
@@ -36,7 +37,7 @@ const verifyConnectionResolver = async (
|
||||
const verifyConnection = {
|
||||
type: connectionType,
|
||||
args: {
|
||||
id: { type: GraphQLNonNull(GraphQLInt) },
|
||||
id: { type: GraphQLNonNull(GraphQLString) },
|
||||
},
|
||||
resolve: (_: any, params: Params, req: RequestWithCurrentUser) =>
|
||||
verifyConnectionResolver(params, req),
|
||||
|
Reference in New Issue
Block a user