UNPKG

@redocly/graphql-docs

Version:

Redocly GraphQL docs

2 lines (1 loc) 506 B
import{getIntrospectionQuery as s}from"graphql";async function c(r,t){if(!global.fetch)throw new Error("GraphQL API introspection is not supported outside of a browser.");const o=JSON.stringify({query:s()}),e=await fetch(r,{method:"POST",headers:i(t),body:o}).then(n=>n.json());if(e.errors)throw new Error("GraphQL service replied with errors: "+JSON.stringify(e.errors));return e.data}function i(r){return{"Content-Type":"application/json",Accept:"application/json",...r}}export{c as fetchIntrospection};