UNPKG

graphile-test

Version:
35 lines (34 loc) 1.05 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.GraphQLTest = void 0; const context_1 = require("./context"); const postgraphile_1 = require("postgraphile"); const graphile_settings_1 = require("graphile-settings"); const GraphQLTest = (input, conn) => { const { schemas, authRole } = input; let schema; let options; const pgPool = conn.manager.getPool(conn.pg.config); const setup = async () => { options = (0, graphile_settings_1.getGraphileSettings)({ graphile: { schema: schemas } }); schema = await (0, postgraphile_1.createPostGraphileSchema)(pgPool, schemas, options); }; const teardown = async () => { }; const query = async (opts) => { return await (0, context_1.runGraphQLInContext)({ input, schema, options, authRole, pgPool, conn, ...opts }); }; return { setup, teardown, query }; }; exports.GraphQLTest = GraphQLTest;