UNPKG

graphile-build-pg

Version:

Build a GraphQL schema by reflection over a PostgreSQL schema. Easy to customize since it's built with plugins on graphile-build

28 lines (26 loc) 730 B
// @flow import type { Plugin } from "graphile-build"; export default (function PgColumnDeprecationPlugin(builder) { builder.hook( "GraphQLObjectType:fields:field", (field, build, context) => { const { scope: { pgFieldIntrospection }, } = context; if ( !pgFieldIntrospection || !pgFieldIntrospection.tags || !pgFieldIntrospection.tags.deprecated ) { return field; } return { ...field, deprecationReason: Array.isArray(pgFieldIntrospection.tags.deprecated) ? pgFieldIntrospection.tags.deprecated.join("\n") : pgFieldIntrospection.tags.deprecated, }; }, ["PgColumnDeprecation"] ); }: Plugin);