UNPKG

@apollo/core-schema

Version:
26 lines 963 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Parser = exports.gql = void 0; const graphql_1 = require("graphql"); const parser_1 = require("graphql/language/parser"); function gql(body, opts) { const name = typeof opts === 'string' ? opts : opts === null || opts === void 0 ? void 0 : opts.name; const source = new graphql_1.Source(String.raw(body), name); const parser = new Parser(source, typeof opts === 'object' ? opts : {}); return parser.parseDocument(); } exports.gql = gql; exports.default = gql; class Parser extends parser_1.Parser { parseDefinition() { if (this.peek(graphql_1.TokenKind.AT)) { return this.node(this._lexer.token, { kind: graphql_1.Kind.SCHEMA_EXTENSION, directives: this.parseDirectives(true) }); } return super.parseDefinition(); } } exports.Parser = Parser; //# sourceMappingURL=gql.js.map