forked from DebaucheryLibrarian/traxxx
48 lines
1.2 KiB
JavaScript
48 lines
1.2 KiB
JavaScript
'use strict';
|
|
|
|
const config = require('config');
|
|
|
|
const { postgraphile } = require('postgraphile');
|
|
|
|
const PgConnectionFilterPlugin = require('postgraphile-plugin-connection-filter');
|
|
const PgSimplifyInflectorPlugin = require('@graphile-contrib/pg-simplify-inflector');
|
|
const PgOrderByRelatedPlugin = require('@graphile-contrib/pg-order-by-related');
|
|
|
|
const { ActorPlugins, SitePlugins, ReleasePlugins } = require('./plugins/plugins');
|
|
|
|
const connectionString = `postgres://${config.database.query.user}:${config.database.query.password}@${config.database.query.host}:5432/${config.database.query.database}`;
|
|
|
|
async function pgSettings(req) {
|
|
return {
|
|
'user.id': req.session.user?.id,
|
|
};
|
|
}
|
|
|
|
module.exports = postgraphile(
|
|
connectionString,
|
|
'public',
|
|
{
|
|
// watchPg: true,
|
|
dynamicJson: true,
|
|
graphiql: true,
|
|
enhanceGraphiql: true,
|
|
allowExplain: () => true,
|
|
// simpleCollections: 'only',
|
|
simpleCollections: 'both',
|
|
graphileBuildOptions: {
|
|
pgOmitListSuffix: true,
|
|
connectionFilterRelations: true,
|
|
connectionFilterAllowNullInput: true,
|
|
},
|
|
appendPlugins: [
|
|
PgSimplifyInflectorPlugin,
|
|
PgConnectionFilterPlugin,
|
|
PgOrderByRelatedPlugin,
|
|
...ActorPlugins,
|
|
...SitePlugins,
|
|
...ReleasePlugins,
|
|
],
|
|
pgSettings,
|
|
},
|
|
);
|