UNPKG

@redocly/graphql-docs

Version:

Redocly GraphQL docs

2 lines (1 loc) 1.75 kB
var u=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var E=Object.prototype.hasOwnProperty;var F=(r,e)=>{for(var t in e)u(r,t,{get:e[t],enumerable:!0})},I=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of y(e))!E.call(r,o)&&o!==t&&u(r,o,{get:()=>e[o],enumerable:!(n=g(e,o))||n.enumerable});return r};var b=r=>I(u({},"__esModule",{value:!0}),r);var _={};F(_,{getGraphQlSchema:()=>v});module.exports=b(_);var h=require("graphql"),i=require("../schema-input-types"),p=require("./fetch-introspection"),l=function(r,e,t,n){function o(a){return a instanceof t?a:new t(function(s){s(a)})}return new(t||(t=Promise))(function(a,s){function w(c){try{m(n.next(c))}catch(f){s(f)}}function S(c){try{m(n.throw(c))}catch(f){s(f)}}function m(c){c.done?a(c.value):o(c.value).then(w,S)}m((n=n.apply(r,e||[])).next())})};function v(r){return l(this,void 0,void 0,function*(){if((0,i.isSdlSchemaInput)(r))return G(r.sdl);if((0,i.isIntrospectionInput)(r))return d(r.introspection);if((0,i.isApiSchemaInput)(r))return Q(r.url,r.headers);if((0,i.isPrebuiltSchema)(r))return r.graphql;throw new Error("Unknown schema type")})}function G(r){try{return(0,h.buildSchema)(r)}catch(e){const t=e instanceof Error&&e.message;throw new Error("Failed building schema from SDL. "+t)}}function d(r){try{return(0,h.buildClientSchema)(r)}catch(e){const t=e instanceof Error&&e.message;throw new Error("Failed building schema from introspection. "+t)}}function Q(r,e){return l(this,void 0,void 0,function*(){let t;try{t=yield(0,p.fetchIntrospection)(r,e)}catch(n){const o=n instanceof Error&&n.message;throw new Error("Failed fetching schema introspection. "+o)}return d(t)})}0&&(module.exports={getGraphQlSchema});