1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, '__esModule', { value: true });
|
4 |
|
5 | const graphql = require('graphql');
|
6 | const pluginHelpers = require('@graphql-codegen/plugin-helpers');
|
7 | const path = require('path');
|
8 |
|
9 | const 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 | };
|
14 | const 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 |
|
20 | exports.plugin = plugin;
|
21 | exports.validate = validate;
|
22 |
|