UNPKG

graphile-settings

Version:
27 lines (26 loc) 1.05 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.MetaSchemaPlugin = void 0; const cache_1 = require("./cache"); const graphql_meta_field_1 = require("./graphql-meta-field"); const table_meta_builder_1 = require("./table-meta-builder"); exports.MetaSchemaPlugin = { name: 'MetaSchemaPlugin', version: '1.0.0', description: 'Exposes _meta query for database schema introspection', schema: { hooks: { init(input, rawBuild) { const build = rawBuild; (0, cache_1.setCachedTablesMeta)((0, table_meta_builder_1.collectTablesMeta)(build)); return input; }, GraphQLObjectType_fields(rawFields, _rawBuild, rawContext) { const context = rawContext; if (context.Self?.name !== 'Query') return rawFields; return (0, graphql_meta_field_1.extendQueryWithMetaField)(rawFields, (0, cache_1.getCachedTablesMeta)()); }, }, }, };