UNPKG

879 BJavaScriptView Raw
1'use strict';
2
3Object.defineProperty(exports, '__esModule', { value: true });
4
5const graphql = require('graphql');
6const pluginHelpers = require('@graphql-codegen/plugin-helpers');
7const path = require('path');
8
9const plugin = async (schema, _documents, pluginConfig) => {
10 const cleanSchema = pluginConfig.federation ? pluginHelpers.removeFederation(schema) : schema;
11 const introspection = graphql.introspectionFromSchema(cleanSchema, { descriptions: true });
12 return pluginConfig.minify ? JSON.stringify(introspection) : JSON.stringify(introspection, null, 2);
13};
14const validate = async (schema, documents, config, outputFile) => {
15 if (path.extname(outputFile) !== '.json') {
16 throw new Error(`Plugin "introspection" requires extension to be ".json"!`);
17 }
18};
19
20exports.plugin = plugin;
21exports.validate = validate;
22//# sourceMappingURL=index.cjs.js.map