@magidoc/rollup-plugin-gql-schema
Version:
A Rollup and ViteJS plugin that allows to parse a GraphQL Schema from a target URL and save it to a target output folder, or to parse it from the disk and convert it to a desired format.
17 lines (14 loc) • 484 B
JavaScript
import { introspectionFromSchema } from 'graphql';
import { printSchemaWithDirectives } from './print.js';
function convert(schema, format) {
switch (format) {
case 'sdl':
return printSchemaWithDirectives(schema);
case 'introspection':
return JSON.stringify(introspectionFromSchema(schema));
default:
throw new Error(`Unknown format ${String(format)}`);
}
}
export { convert };
//# sourceMappingURL=convert.js.map