UNPKG

1.04 kBJavaScriptView Raw
1"use strict";
2var request = require("request");
3var introspectionQuery_1 = require("graphql/utilities/introspectionQuery");
4exports.introspectionFromUrl = function (url) {
5 return new Promise(function (resolve, reject) {
6 request.post({
7 url: url,
8 json: {
9 query: introspectionQuery_1.introspectionQuery
10 },
11 headers: {
12 'Accept': 'application/json',
13 'Content-Type': 'application/json'
14 }
15 }, function (err, response, body) {
16 if (err) {
17 reject(err);
18 return;
19 }
20 var bodyJson = body.data;
21 if (!bodyJson || (bodyJson.errors && bodyJson.errors.length > 0)) {
22 reject('Unable to download schema from remote: ' + bodyJson.errors.map(function (item) { return item.message; }).join(', '));
23 return;
24 }
25 resolve(bodyJson);
26 });
27 });
28};
29//# sourceMappingURL=introspection-from-url.js.map
\No newline at end of file