-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.js
38 lines (33 loc) · 1.17 KB
/
index.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
const PostgisOperatorsPlugin = require("./src/PgConnectionArgFilterPostgisOperatorsPlugin.js");
module.exports = function PostGraphileConnectionFilterPostgisPlugin(
builder,
options
) {
builder.hook("build", build => {
const pkg = require("./package.json");
// Check dependencies
if (!build.versions) {
throw new Error(
`Plugin ${pkg.name}@${pkg.version} requires graphile-build@^4.1.0 in order to check dependencies (current version: ${build.graphileBuildVersion})`
);
}
const depends = (name, range) => {
if (!build.hasVersion(name, range)) {
throw new Error(
`Plugin ${pkg.name}@${pkg.version} requires ${name}@${range} (${
build.versions[name]
? `current version: ${build.versions[name]}`
: "not found"
})`
);
}
};
depends("graphile-build-pg", "^4.5.0");
depends("postgraphile-plugin-connection-filter", "^2.0.0");
//depends("@graphile/postgis", "0.1.0");
// Register this plugin
build.versions = build.extend(build.versions, { [pkg.name]: pkg.version });
return build;
});
PostgisOperatorsPlugin(builder, options);
};