UNPKG

@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.

43 lines (42 loc) 1.46 kB
import type { Plugin } from 'rollup'; import { type OutputFormat } from '../schema/convert.js'; import { type Method } from '../schema/query.js'; export type { Method }; export type PluginOptions = { /** * The URL the of the GraphQL API from which to fetch the GraphQL Schema using the introspection query. */ url: string; /** * The Introspection Query the use. Some GraphQL APIs do not respect the standard schema fir GraphQL introspection query used by GraphQL.js * * This overrides the query generated by GraphQL with a custom one. */ query?: string; /** * Wether the output format should be a GraphQL SDL file or an introspection JSON file. * * Defaults to introspection JSON. */ format?: OutputFormat; /** * The HTTP method used to call the GraphQL API. * * @default 'POST' */ method?: Method; /** * A record of headers to pass inside the GraphQL Request performed to the server. Mostly useful when Authorization is required. * * @default {"Content-Type": "application/json"} */ headers?: Record<string, string>; /** * Indicates the target path for the JSON Schema resulting from the Query. * * @default src/_schema.json */ target?: string; }; export declare function fetchSchema(options: PluginOptions): Promise<void>; export default function fetchGraphQLSchema(options: PluginOptions): Plugin;