graphql-config
Advanced tools
Comparing version 1.0.0-rc.4 to 1.0.0-rc.5
@@ -5,2 +5,4 @@ "use strict"; | ||
var path_1 = require("path"); | ||
var fs_1 = require("fs"); | ||
var os_1 = require("os"); | ||
var schema = require('../schema.json'); | ||
@@ -13,4 +15,6 @@ var _1 = require("../../"); | ||
ava_1.default('throws GraphQLConfigNotFoundError when config is not found', function (t) { | ||
var tempDir = fs_1.mkdtempSync(path_1.join(os_1.tmpdir(), 'graphql-config')); | ||
var path; | ||
try { | ||
_1.findGraphQLConfigFile(path_1.dirname(__dirname)); | ||
path = _1.findGraphQLConfigFile(tempDir); | ||
} | ||
@@ -21,4 +25,4 @@ catch (error) { | ||
} | ||
; | ||
console.log(path, tempDir); | ||
t.fail('findGraphQLConfigFile should throw when config is not found'); | ||
}); |
import { GraphQLClient } from 'graphql-request'; | ||
import { GraphQLSchema } from 'graphql'; | ||
import { IntrospectionResult } from '../../types'; | ||
export declare type GraphQLConfigEnpointsSubscription = { | ||
@@ -40,3 +41,5 @@ url: string; | ||
getClient(clientOptions?: any): GraphQLClient; | ||
resolveIntrospection(): Promise<IntrospectionResult>; | ||
resolveSchema(): Promise<GraphQLSchema>; | ||
resolveSchemaSDL(): Promise<string>; | ||
} |
@@ -10,2 +10,37 @@ "use strict"; | ||
}; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
var __generator = (this && this.__generator) || function (thisArg, body) { | ||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | ||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||
function verb(n) { return function (v) { return step([n, v]); }; } | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t; | ||
if (y = 0, t) op = [0, t.value]; | ||
switch (op[0]) { | ||
case 0: case 1: t = op; break; | ||
case 4: _.label++; return { value: op[1], done: false }; | ||
case 5: _.label++; y = op[1]; op = [0]; continue; | ||
case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||
} | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -74,10 +109,45 @@ var graphql_request_1 = require("graphql-request"); | ||
}; | ||
GraphQLEndpoint.prototype.resolveIntrospection = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var client, data; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
client = this.getClient(); | ||
return [4 /*yield*/, client.request(graphql_1.introspectionQuery)]; | ||
case 1: | ||
data = _a.sent(); | ||
return [2 /*return*/, { data: data }]; | ||
} | ||
}); | ||
}); | ||
}; | ||
GraphQLEndpoint.prototype.resolveSchema = function () { | ||
var client = this.getClient(); | ||
return client.request(graphql_1.introspectionQuery).then(function (introspection) { | ||
return graphql_1.buildClientSchema(introspection); | ||
return __awaiter(this, void 0, void 0, function () { | ||
var introspection; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.resolveIntrospection()]; | ||
case 1: | ||
introspection = _a.sent(); | ||
return [2 /*return*/, graphql_1.buildClientSchema(introspection.data)]; | ||
} | ||
}); | ||
}); | ||
}; | ||
GraphQLEndpoint.prototype.resolveSchemaSDL = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var schema; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.resolveSchema()]; | ||
case 1: | ||
schema = _a.sent(); | ||
return [2 /*return*/, graphql_1.printSchema(schema)]; | ||
} | ||
}); | ||
}); | ||
}; | ||
return GraphQLEndpoint; | ||
}()); | ||
exports.GraphQLEndpoint = GraphQLEndpoint; |
@@ -126,3 +126,3 @@ "use strict"; | ||
/* | ||
extension relatad helper functions | ||
extension related helper functions | ||
*/ | ||
@@ -129,0 +129,0 @@ get: function () { |
import { IntrospectionQuery } from 'graphql'; | ||
import { GraphQLConfigEnpointsData } from './extensions/'; | ||
export declare type IntrospectionResult = { | ||
data?: IntrospectionQuery; | ||
data: IntrospectionQuery; | ||
errors?: any; | ||
@@ -6,0 +6,0 @@ }; |
{ | ||
"name": "graphql-config", | ||
"version": "1.0.0-rc.4", | ||
"version": "1.0.0-rc.5", | ||
"description": "The easiest way to configure your development environment with your GraphQL schema (supported by most tools, editors & IDEs)", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
66836
1287
9