metamigo-api: runs in docker now

* great typescript module import refactor
* refactor metamigo-cli so it is the entrypoint for the db, api, and
  worker
This commit is contained in:
Abel Luck 2023-06-02 14:05:20 +00:00
parent b45e2e8c11
commit 696ba16cb7
78 changed files with 319 additions and 180 deletions

View file

@ -1,38 +0,0 @@
import { writeFileSync } from "node:fs";
import {
getIntrospectionQuery,
GraphQLSchema,
graphqlSync,
lexicographicSortSchema,
printSchema,
} from "graphql";
import { createPostGraphileSchema } from "postgraphile";
import { Pool } from "pg";
import { loadConfig } from "@digiresilience/metamigo-config";
import { getPostGraphileOptions } from "@digiresilience/metamigo-db";
export const exportGraphqlSchema = async (): Promise<void> => {
const config = await loadConfig();
const rootPgPool = new Pool({
connectionString: config.db.connection,
});
const exportSchema = `../../data/schema.graphql`;
const exportJson = `../../frontend/lib/graphql-schema.json`;
try {
const schema = (await createPostGraphileSchema(
config.postgraphile.authConnection,
"app_public",
getPostGraphileOptions()
)) as unknown as GraphQLSchema;
const sorted = lexicographicSortSchema(schema);
const json = graphqlSync({ schema, source: getIntrospectionQuery() });
writeFileSync(exportSchema, printSchema(sorted));
writeFileSync(exportJson, JSON.stringify(json));
console.log(`GraphQL schema exported to ${exportSchema}`);
console.log(`GraphQL schema json exported to ${exportJson}`);
} finally {
rootPgPool.end();
}
};