-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver-express.js
More file actions
32 lines (28 loc) · 872 Bytes
/
Copy pathserver-express.js
File metadata and controls
32 lines (28 loc) · 872 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
const pg = require('pg');
const express = require('express');
const { postgraphile } = require('postgraphile');
const ConnectionFilterPlugin = require('postgraphile-plugin-connection-filter');
const PgManyToManyPlugin = require('@graphile-contrib/pg-many-to-many');
const app = express();
const pgPool = new pg.Pool({
connectionString: (process.env.DATABASE_URL || 'postgres://postgres:postgres@127.0.0.1/blog'),
});
app.use(
postgraphile(
pgPool,
process.env.SCHEMA_NAMES ? process.env.SCHEMA_NAMES.split(',') : ['lilac'],
{
appendPlugins: [ConnectionFilterPlugin, PgManyToManyPlugin],
graphileBuildOptions: {
connectionFilterRelations: true,
},
watchPg: true,
graphiql: true,
enhanceGraphiql: true,
allowExplain(req) {
return true;
},
}
)
);
app.listen(process.env.PORT || 5002);