-
-
Notifications
You must be signed in to change notification settings - Fork 24
/
.postgraphilerc.js
65 lines (61 loc) · 1.87 KB
/
.postgraphilerc.js
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
const PgSimplifyInflectorPlugin = require("@graphile-contrib/pg-simplify-inflector");
["AUTH_DATABASE_URL", "NODE_ENV"].forEach(envvar => {
if (!process.env[envvar]) {
// We automatically source `.env` in the various scripts; but in case that
// hasn't been done lets raise an error and stop.
console.error("");
console.error("");
console.error("⚠️⚠️⚠️⚠️");
console.error(
`No ${envvar} found in your environment; perhaps you need to run 'source ./.env'?`
);
console.error("⚠️⚠️⚠️⚠️");
console.error("");
process.exit(1);
}
});
const isDev = process.env.NODE_ENV === "development";
// Our database URL - privileged
const ownerConnection = process.env.ROOT_DATABASE_URL;
// Our database URL - unprivileged
const connection = process.env.AUTH_DATABASE_URL;
// The PostgreSQL schema within our postgres DB to expose
const schema = ["app_public"];
// Enable GraphiQL interface
const graphiql = true;
// Send back JSON objects rather than JSON strings
const dynamicJson = true;
// Watch the database for changes
const watch = true;
// Add some Graphile-Build plugins to enhance our GraphQL schema
const appendPlugins = [
// Removes the 'ByFooIdAndBarId' from the end of relations
PgSimplifyInflectorPlugin,
];
module.exports = {
// Config for the library (middleware):
library: {
connection,
schema,
options: {
ownerConnectionString: ownerConnection,
dynamicJson,
graphiql,
watchPg: watch,
appendPlugins,
},
},
// Options for the CLI:
options: {
ownerConnection,
defaultRole: "graphiledemo_visitor",
connection,
schema,
dynamicJson,
disableGraphiql: !graphiql,
enhanceGraphiql: true,
ignoreRbac: false,
// We don't set a watch mode here, because there's no way to turn it off (e.g. when using -X) currently.
appendPlugins,
},
};