Skip to content

Instantly share code, notes, and snippets.

@benjie
Created May 21, 2021 15:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benjie/cb0953e575377b29cb3260455391013d to your computer and use it in GitHub Desktop.
Save benjie/cb0953e575377b29cb3260455391013d to your computer and use it in GitHub Desktop.
A Graphile Engine plugin to strip all tags/descriptions from introspection results
module.exports = (builder) => {
builder.hook("build", (build) => {
const oldPgAugmentIntrospectionResults =
build.pgAugmentIntrospectionResults;
build.pgAugmentIntrospectionResults = (inIntrospectionResult) => {
let pgIntrospectionResultsByKind = inIntrospectionResult;
if (oldPgAugmentIntrospectionResults) {
pgIntrospectionResultsByKind = oldPgAugmentIntrospectionResults(
pgIntrospectionResultsByKind,
);
}
const strip = (entity) => {
// Delete old tags
// TODO: don't erase `@enum` and related tags!
entity.tags = {};
entity.description = null;
};
pgIntrospectionResultsByKind.attribute.forEach(strip);
pgIntrospectionResultsByKind.class.forEach(strip);
pgIntrospectionResultsByKind.constraint.forEach(strip);
pgIntrospectionResultsByKind.extension.forEach(strip);
pgIntrospectionResultsByKind.index.forEach(strip);
pgIntrospectionResultsByKind.namespace.forEach(strip);
pgIntrospectionResultsByKind.procedure.forEach(strip);
pgIntrospectionResultsByKind.type.forEach(strip);
return pgIntrospectionResultsByKind;
};
return build;
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment