@graphile/postgis
Version:
PostGIS support for PostGraphile
29 lines • 1.42 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const debug_1 = require("./debug");
const plugin = builder => {
builder.hook("build", build => {
const { pgIntrospectionResultsByKind: introspectionResultsByKind } = build;
const pgGISExtension = introspectionResultsByKind.extension.find((e) => e.name === "postgis");
// Check we have the postgis extension
if (!pgGISExtension) {
debug_1.default("PostGIS extension not found in database; skipping");
return build;
}
// Extract the geography and geometry types
const pgGISGeometryType = introspectionResultsByKind.type.find((t) => t.name === "geometry" && t.namespaceId === pgGISExtension.namespaceId);
const pgGISGeographyType = introspectionResultsByKind.type.find((t) => t.name === "geography" && t.namespaceId === pgGISExtension.namespaceId);
if (!pgGISGeographyType || !pgGISGeometryType) {
throw new Error("PostGIS is installed, but we couldn't find the geometry/geography types!");
}
return build.extend(build, {
pgGISGraphQLTypesByTypeAndSubtype: {},
pgGISGraphQLInterfaceTypesByType: {},
pgGISGeometryType,
pgGISGeographyType,
pgGISExtension,
});
});
};
exports.default = plugin;
//# sourceMappingURL=PostgisExtensionDetectionPlugin.js.map