Files
automatisch/packages/backend/src/graphql/queries/get-data.ts
Ali BARIN 75eda7f2af feat(cli): run migrations and app in start command (#284)
* feat: perform pending migrations in start command

* feat: log error when DB connection is refused

* feat: log error when Redis connection is refused

* refactor: fix type errors

* fix: correct server and copy graphql schema

* fix: differentiate migrations by env

* chore: remove dev executable

* chore: fix typo in default postgresUsername

* fix: copy json files into dist folder

* chore(cli): add dev script

* chore: pull non-dev logs to info level

* feat(cli): run app in start command

* fix(backend): remove default count in Connection

* fix(cli): remove .eslintrc usage in lint script

* refactor: remove disableMigrationsListValidation

* refactor: make Step optional in ExecutionStep

* refactor: make Flow optional in Step
2022-04-08 11:27:46 +02:00

32 lines
807 B
TypeScript

import App from '../../models/app';
import Context from '../../types/express/context';
type Params = {
stepId: string;
key: string;
};
const getData = async (_parent: unknown, params: Params, context: Context) => {
const step = await context.currentUser
.$relatedQuery('steps')
.withGraphFetched('connection')
.findById(params.stepId);
if (!step) return null;
const connection = step.connection;
if (!connection || !step.appKey) return null;
const appData = App.findOneByKey(step.appKey);
const AppClass = (await import(`../../apps/${step.appKey}`)).default;
const appInstance = new AppClass(appData, connection.formattedData);
const command = appInstance.data[params.key];
const fetchedData = await command.run();
return fetchedData;
};
export default getData;