Socket
Socket
Sign inDemoInstall

graphql-config

Package Overview
Dependencies
Maintainers
2
Versions
319
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphql-config - npm Package Compare versions

Comparing version 1.0.0-rc.1 to 1.0.0-rc.2

14

lib/__tests__/basic/findGraphQLConfigFile.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const ava_1 = require("ava");
const path_1 = require("path");
const schema = require('../schema.json');
const _1 = require("../../");
ava_1.default('returns a correct config filename', (t) => {
const configFile = _1.findGraphQLConfigFile(__dirname);
var ava_1 = require("ava");
var path_1 = require("path");
var schema = require('../schema.json');
var _1 = require("../../");
ava_1.default('returns a correct config filename', function (t) {
var configFile = _1.findGraphQLConfigFile(__dirname);
t.deepEqual(configFile, path_1.join(__dirname, '.graphqlconfig'));
});
ava_1.default('throws GraphQLConfigNotFoundError when config is not found', (t) => {
ava_1.default('throws GraphQLConfigNotFoundError when config is not found', function (t) {
try {

@@ -13,0 +13,0 @@ _1.findGraphQLConfigFile(path_1.dirname(__dirname));

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const ava_1 = require("ava");
const path_1 = require("path");
const schema = require('../schema.json');
const _1 = require("../../");
const CONFIG_DIR = path_1.join(__dirname, 'config');
let config;
ava_1.default.beforeEach(() => {
var ava_1 = require("ava");
var path_1 = require("path");
var schema = require('../schema.json');
var _1 = require("../../");
var CONFIG_DIR = path_1.join(__dirname, 'config');
var config;
ava_1.default.beforeEach(function () {
config = _1.getGraphQLConfig(CONFIG_DIR);
});
ava_1.default('returns a correct name', (t) => {
const testWithSchemaConfig = config.getProjectConfig('testWithSchema');
ava_1.default('returns a correct name', function (t) {
var testWithSchemaConfig = config.getProjectConfig('testWithSchema');
t.deepEqual(testWithSchemaConfig.projectName, 'testWithSchema');
});
ava_1.default('returns a correct root dir', (t) => t.deepEqual(config.configDir, CONFIG_DIR));
ava_1.default('returns a correct schema path', (t) => {
ava_1.default('returns a correct root dir', function (t) { return t.deepEqual(config.configDir, CONFIG_DIR); });
ava_1.default('returns a correct schema path', function (t) {
t.deepEqual(config.getProjectConfig('testWithSchema').schemaPath, path_1.join(CONFIG_DIR, '__schema__/StarWarsSchema.graphql'));
t.deepEqual(config.getProjectConfig('testWithoutSchema').schemaPath, null);
});

@@ -10,10 +10,47 @@ "use strict";

};
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 };
}
};
var _this = this;
Object.defineProperty(exports, "__esModule", { value: true });
const ava_1 = require("ava");
const schema = require('../schema.json');
const _1 = require("../../");
ava_1.default('resolves schema from file', (t) => __awaiter(this, void 0, void 0, function* () {
const config = _1.getGraphQLProjectConfig(__dirname);
const resolvedSchema = yield config.resolveIntrospection();
t.deepEqual(resolvedSchema, schema);
}));
var ava_1 = require("ava");
var schema = require('../schema.json');
var _1 = require("../../");
ava_1.default('resolves schema from file', function (t) { return __awaiter(_this, void 0, void 0, function () {
var config, resolvedSchema;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
config = _1.getGraphQLProjectConfig(__dirname);
return [4 /*yield*/, config.resolveIntrospection()];
case 1:
resolvedSchema = _a.sent();
t.deepEqual(resolvedSchema, schema);
return [2 /*return*/];
}
});
}); });

@@ -10,99 +10,158 @@ "use strict";

};
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 };
}
};
var _this = this;
Object.defineProperty(exports, "__esModule", { value: true });
const ava_1 = require("ava");
const graphql_1 = require("graphql");
const _1 = require("../../");
const utils_1 = require("../utils");
const introspection = require('../schema.json');
ava_1.default.before((t) => __awaiter(this, void 0, void 0, function* () {
return yield utils_1.serveSchema();
}));
const confPath = `${__dirname}/.graphqlconfig`;
ava_1.default('getEndpointsMap when endpoint is string url', (t) => __awaiter(this, void 0, void 0, function* () {
const configData = {
schemaPath: '../schema.json',
extensions: {
endpoint: 'http://default',
},
};
const config = new _1.GraphQLProjectConfig(configData, confPath);
const endpoint = config.endpointExtension;
t.deepEqual(endpoint && endpoint.getRawEndpointsMap(), { default: { url: 'http://default' } });
}));
ava_1.default('getEndpointsMap when endpoint is single endpoint config', (t) => __awaiter(this, void 0, void 0, function* () {
const configData = {
schemaPath: '../schema.json',
extensions: {
endpoint: {
url: 'http://default',
subscription: {
url: 'ws://test',
},
var ava_1 = require("ava");
var graphql_1 = require("graphql");
var _1 = require("../../");
var utils_1 = require("../utils");
var introspection = require('../schema.json');
ava_1.default.before(function (t) { return __awaiter(_this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, utils_1.serveSchema()];
case 1: return [2 /*return*/, _a.sent()];
}
});
}); });
var confPath = __dirname + "/.graphqlconfig";
ava_1.default('getEndpointsMap when endpoint is string url', function (t) { return __awaiter(_this, void 0, void 0, function () {
var configData, config, endpoint;
return __generator(this, function (_a) {
configData = {
schemaPath: '../schema.json',
extensions: {
endpoint: 'http://default',
},
},
};
const config = new _1.GraphQLProjectConfig(configData, confPath, undefined);
const endpoint = config.endpointExtension;
t.deepEqual(endpoint && endpoint.getRawEndpointsMap(), { default: configData.extensions.endpoint });
}));
ava_1.default('getEndpointsMap when endpoint is endpoints map', (t) => __awaiter(this, void 0, void 0, function* () {
const configData = {
schemaPath: '../schema.json',
extensions: {
endpoint: {
dev: {
url: 'http://dev',
};
config = new _1.GraphQLProjectConfig(configData, confPath);
endpoint = config.endpointExtension;
t.deepEqual(endpoint && endpoint.getRawEndpointsMap(), { default: { url: 'http://default' } });
return [2 /*return*/];
});
}); });
ava_1.default('getEndpointsMap when endpoint is single endpoint config', function (t) { return __awaiter(_this, void 0, void 0, function () {
var configData, config, endpoint;
return __generator(this, function (_a) {
configData = {
schemaPath: '../schema.json',
extensions: {
endpoint: {
url: 'http://default',
subscription: {
url: 'ws://dev',
url: 'ws://test',
},
},
prod: {
url: 'http://prod',
subscription: {
url: 'ws://prod',
},
};
config = new _1.GraphQLProjectConfig(configData, confPath, undefined);
endpoint = config.endpointExtension;
t.deepEqual(endpoint && endpoint.getRawEndpointsMap(), { default: configData.extensions.endpoint });
return [2 /*return*/];
});
}); });
ava_1.default('getEndpointsMap when endpoint is endpoints map', function (t) { return __awaiter(_this, void 0, void 0, function () {
var configData, config, endpoint;
return __generator(this, function (_a) {
configData = {
schemaPath: '../schema.json',
extensions: {
endpoint: {
dev: {
url: 'http://dev',
subscription: {
url: 'ws://dev',
},
},
prod: {
url: 'http://prod',
subscription: {
url: 'ws://prod',
},
},
},
},
},
};
const config = new _1.GraphQLProjectConfig(configData, confPath, undefined);
const endpoint = config.endpointExtension;
t.deepEqual(endpoint && endpoint.getRawEndpointsMap(), configData.extensions.endpoint);
}));
ava_1.default('resolveSchemaFromEndpoint should throw if non-existing endpoint is specified', (t) => __awaiter(this, void 0, void 0, function* () {
const configData = {
schemaPath: '../schema.json',
extensions: {
endpoint: {
dev: {
url: 'http://dev',
subscription: {
url: 'ws://dev',
};
config = new _1.GraphQLProjectConfig(configData, confPath, undefined);
endpoint = config.endpointExtension;
t.deepEqual(endpoint && endpoint.getRawEndpointsMap(), configData.extensions.endpoint);
return [2 /*return*/];
});
}); });
ava_1.default('resolveSchemaFromEndpoint should throw if non-existing endpoint is specified', function (t) { return __awaiter(_this, void 0, void 0, function () {
var configData, config, error, endpoint;
return __generator(this, function (_a) {
configData = {
schemaPath: '../schema.json',
extensions: {
endpoint: {
dev: {
url: 'http://dev',
subscription: {
url: 'ws://dev',
},
},
},
},
},
};
const config = new _1.GraphQLProjectConfig(configData, confPath, undefined);
let error;
const endpoint = config.endpointExtension;
error = t.throws(() => endpoint && endpoint.getEndpoint('prod').resolveSchema());
t.regex(error.message, /^Endpoint.*is not defined/);
error = t.throws(() => endpoint && endpoint.getEndpoint('prod').resolveSchema());
t.regex(error.message, /^Endpoint.*is not defined/);
}));
ava_1.default('resolveSchemaFromEndpoint HTTP', (t) => __awaiter(this, void 0, void 0, function* () {
const configData = {
schemaPath: '../schema.json',
extensions: {
endpoint: 'http://127.0.0.1:33333',
},
};
const config = new _1.GraphQLProjectConfig(configData, confPath, undefined);
if (!config.endpointExtension) {
throw 'endpointExtension can\'t be empty';
}
const schema = yield config.endpointExtension.getEndpoint().resolveSchema();
const resolvedIntrospection = yield graphql_1.graphql(schema, graphql_1.introspectionQuery);
t.deepEqual(resolvedIntrospection, introspection);
}));
};
config = new _1.GraphQLProjectConfig(configData, confPath, undefined);
endpoint = config.endpointExtension;
error = t.throws(function () { return endpoint && endpoint.getEndpoint('prod').resolveSchema(); });
t.regex(error.message, /^Endpoint.*is not defined/);
error = t.throws(function () { return endpoint && endpoint.getEndpoint('prod').resolveSchema(); });
t.regex(error.message, /^Endpoint.*is not defined/);
return [2 /*return*/];
});
}); });
ava_1.default('resolveSchemaFromEndpoint HTTP', function (t) { return __awaiter(_this, void 0, void 0, function () {
var configData, config, schema, resolvedIntrospection;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
configData = {
schemaPath: '../schema.json',
extensions: {
endpoint: 'http://127.0.0.1:33333',
},
};
config = new _1.GraphQLProjectConfig(configData, confPath, undefined);
if (!config.endpointExtension) {
throw 'endpointExtension can\'t be empty';
}
return [4 /*yield*/, config.endpointExtension.getEndpoint().resolveSchema()];
case 1:
schema = _a.sent();
return [4 /*yield*/, graphql_1.graphql(schema, graphql_1.introspectionQuery)];
case 2:
resolvedIntrospection = _a.sent();
t.deepEqual(resolvedIntrospection, introspection);
return [2 /*return*/];
}
});
}); });

@@ -10,34 +10,82 @@ "use strict";

};
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 };
}
};
var _this = this;
Object.defineProperty(exports, "__esModule", { value: true });
const ava_1 = require("ava");
const _1 = require("../../");
const utils_1 = require("../utils");
let endpoint;
ava_1.default.beforeEach(() => {
var ava_1 = require("ava");
var _1 = require("../../");
var utils_1 = require("../utils");
var endpoint;
ava_1.default.beforeEach(function () {
endpoint = _1.getGraphQLProjectConfig().endpointExtension;
});
ava_1.default('getEndpointsMap', (t) => __awaiter(this, void 0, void 0, function* () {
t.deepEqual(endpoint.getRawEndpointsMap(), {
default: {
url: '${env:TEST_ENDPOINT_URL}',
},
ava_1.default('getEndpointsMap', function (t) { return __awaiter(_this, void 0, void 0, function () {
return __generator(this, function (_a) {
t.deepEqual(endpoint.getRawEndpointsMap(), {
default: {
url: '${env:TEST_ENDPOINT_URL}',
},
});
return [2 /*return*/];
});
}));
ava_1.default('getEndpointEnvVars should returns null for undefined env var', (t) => __awaiter(this, void 0, void 0, function* () {
t.deepEqual(endpoint.getEnvVarsForEndpoint('default'), { TEST_ENDPOINT_URL: null });
}));
ava_1.default('getEndpointEnvVars should returns value for defined env var', (t) => __awaiter(this, void 0, void 0, function* () {
const testURL = 'http://test.com';
process.env['TEST_ENDPOINT_URL'] = testURL;
t.deepEqual(endpoint.getEnvVarsForEndpoint('default'), { TEST_ENDPOINT_URL: testURL });
delete process.env['TEST_ENDPOINT_URL'];
}));
ava_1.default('resolveSchemaFromEndpoint should throw when not all env variables are set', (t) => __awaiter(this, void 0, void 0, function* () {
t.throws(() => endpoint.getEndpoint('default').resolveSchema());
}));
ava_1.default('ability to pass external values as env vars to resolveSchemaFromEndpoint', (t) => __awaiter(this, void 0, void 0, function* () {
yield utils_1.serveSchema();
t.notThrows(() => {
return endpoint.getEndpoint('default', { TEST_ENDPOINT_URL: 'http://127.0.0.1:33333' }).resolveSchema();
}); });
ava_1.default('getEndpointEnvVars should returns null for undefined env var', function (t) { return __awaiter(_this, void 0, void 0, function () {
return __generator(this, function (_a) {
t.deepEqual(endpoint.getEnvVarsForEndpoint('default'), { TEST_ENDPOINT_URL: null });
return [2 /*return*/];
});
}));
}); });
ava_1.default('getEndpointEnvVars should returns value for defined env var', function (t) { return __awaiter(_this, void 0, void 0, function () {
var testURL;
return __generator(this, function (_a) {
testURL = 'http://test.com';
process.env['TEST_ENDPOINT_URL'] = testURL;
t.deepEqual(endpoint.getEnvVarsForEndpoint('default'), { TEST_ENDPOINT_URL: testURL });
delete process.env['TEST_ENDPOINT_URL'];
return [2 /*return*/];
});
}); });
ava_1.default('resolveSchemaFromEndpoint should throw when not all env variables are set', function (t) { return __awaiter(_this, void 0, void 0, function () {
return __generator(this, function (_a) {
t.throws(function () { return endpoint.getEndpoint('default').resolveSchema(); });
return [2 /*return*/];
});
}); });
ava_1.default('ability to pass external values as env vars to resolveSchemaFromEndpoint', function (t) { return __awaiter(_this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, utils_1.serveSchema()];
case 1:
_a.sent();
t.notThrows(function () {
return endpoint.getEndpoint('default', { TEST_ENDPOINT_URL: 'http://127.0.0.1:33333' }).resolveSchema();
});
return [2 /*return*/];
}
});
}); });
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const schema = require('./schema.json');
const http_1 = require("http");
function serveSchema(port = 33333) {
const handleRequest = (request, response) => {
var schema = require('./schema.json');
var http_1 = require("http");
function serveSchema(port) {
if (port === void 0) { port = 33333; }
var handleRequest = function (request, response) {
response.writeHead(200, { 'Content-Type': 'application/json' });
response.end(JSON.stringify(schema));
};
const server = http_1.createServer(handleRequest);
return new Promise((resolve) => {
var server = http_1.createServer(handleRequest);
return new Promise(function (resolve) {
server.listen(port, resolve);

@@ -13,0 +14,0 @@ });

@@ -10,10 +10,47 @@ "use strict";

};
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 };
}
};
var _this = this;
Object.defineProperty(exports, "__esModule", { value: true });
const ava_1 = require("ava");
const schema = require('../schema.json');
const _1 = require("../../");
ava_1.default((t) => __awaiter(this, void 0, void 0, function* () {
const config = _1.getGraphQLProjectConfig();
const resolvedSchema = yield config.resolveIntrospection();
t.deepEqual(resolvedSchema, schema);
}));
var ava_1 = require("ava");
var schema = require('../schema.json');
var _1 = require("../../");
ava_1.default(function (t) { return __awaiter(_this, void 0, void 0, function () {
var config, resolvedSchema;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
config = _1.getGraphQLProjectConfig();
return [4 /*yield*/, config.resolveIntrospection()];
case 1:
resolvedSchema = _a.sent();
t.deepEqual(resolvedSchema, schema);
return [2 /*return*/];
}
});
}); });
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });

@@ -11,8 +21,15 @@ function ExtendableBuiltin(cls) {

}
class ConfigNotFoundError extends ExtendableBuiltin(Error) {
constructor(...args) {
super(...args);
this.name = this.constructor.name;
var ConfigNotFoundError = (function (_super) {
__extends(ConfigNotFoundError, _super);
function ConfigNotFoundError() {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
var _this = _super.apply(this, args) || this;
_this.name = _this.constructor.name;
return _this;
}
}
return ConfigNotFoundError;
}(ExtendableBuiltin(Error)));
exports.ConfigNotFoundError = ConfigNotFoundError;
"use strict";
var __assign = (this && this.__assign) || Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
Object.defineProperty(exports, "__esModule", { value: true });
const graphql_request_1 = require("graphql-request");
const graphql_1 = require("graphql");
const resolveRefString_1 = require("./resolveRefString");
class GraphQLEndpointExtension {
constructor(endpointConfig, configPath) {
var graphql_request_1 = require("graphql-request");
var graphql_1 = require("graphql");
var resolveRefString_1 = require("./resolveRefString");
var GraphQLEndpointExtension = (function () {
function GraphQLEndpointExtension(endpointConfig, configPath) {
this.raw = endpointConfig;
this.configPath = configPath;
}
getRawEndpointsMap() {
const endpoint = this.raw;
let result;
GraphQLEndpointExtension.prototype.getRawEndpointsMap = function () {
var endpoint = this.raw;
var result;
if (typeof endpoint === 'string') {

@@ -22,3 +30,3 @@ result = {

else if (typeof endpoint !== 'object' || Array.isArray(endpoint)) {
throw new Error(`${this.configPath}: "endpoint" should be string or object`);
throw new Error(this.configPath + ": \"endpoint\" should be string or object");
}

@@ -34,36 +42,42 @@ else if (!endpoint['url']) {

else {
throw new Error(`${this.configPath}: "url" should be a string`);
throw new Error(this.configPath + ": \"url\" should be a string");
}
return result;
}
getEnvVarsForEndpoint(endpointName = process.env.GRAPHQL_CONFIG_ENDPOINT_NAME || 'default') {
const endpoint = this.getRawEndpointsMap()[endpointName];
};
GraphQLEndpointExtension.prototype.getEnvVarsForEndpoint = function (endpointName) {
if (endpointName === void 0) { endpointName = process.env.GRAPHQL_CONFIG_ENDPOINT_NAME || 'default'; }
var endpoint = this.getRawEndpointsMap()[endpointName];
if (!endpoint || !endpoint.url) {
throw new Error(`Endpoint "${endpointName}" is not defined in "${this.configPath}"`);
throw new Error("Endpoint \"" + endpointName + "\" is not defined in \"" + this.configPath + "\"");
}
return resolveRefString_1.getUsedEnvs(endpoint);
}
getEndpoint(endpointName = process.env.GRAPHQL_CONFIG_ENDPOINT_NAME || 'default', env = process.env) {
const endpoint = this.getRawEndpointsMap()[endpointName];
};
GraphQLEndpointExtension.prototype.getEndpoint = function (endpointName, env) {
if (endpointName === void 0) { endpointName = process.env.GRAPHQL_CONFIG_ENDPOINT_NAME || 'default'; }
if (env === void 0) { env = process.env; }
var endpoint = this.getRawEndpointsMap()[endpointName];
if (!endpoint || !endpoint.url) {
throw new Error(`Endpoint "${endpointName}" is not defined in ${this.configPath}`);
throw new Error("Endpoint \"" + endpointName + "\" is not defined in " + this.configPath);
}
return new GraphQLEndpoint(resolveRefString_1.resolveEnvsInValues(endpoint, env));
}
}
};
return GraphQLEndpointExtension;
}());
exports.GraphQLEndpointExtension = GraphQLEndpointExtension;
class GraphQLEndpoint {
constructor(resolvedConfig) {
var GraphQLEndpoint = (function () {
function GraphQLEndpoint(resolvedConfig) {
Object.assign(this, resolvedConfig);
}
getClient(clientOptions = {}) {
return new graphql_request_1.GraphQLClient(this.url, Object.assign({}, clientOptions, { headers: this.headers }));
}
resolveSchema() {
const client = this.getClient();
return client.request(graphql_1.introspectionQuery).then(introspection => {
GraphQLEndpoint.prototype.getClient = function (clientOptions) {
if (clientOptions === void 0) { clientOptions = {}; }
return new graphql_request_1.GraphQLClient(this.url, __assign({}, clientOptions, { headers: this.headers }));
};
GraphQLEndpoint.prototype.resolveSchema = function () {
var client = this.getClient();
return client.request(graphql_1.introspectionQuery).then(function (introspection) {
return graphql_1.buildClientSchema(introspection);
});
}
}
};
return GraphQLEndpoint;
}());
exports.GraphQLEndpoint = GraphQLEndpoint;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function resolveRefString(str, values) {
const { strings, rawRefs } = parse(str);
const refValues = rawRefs.map(ref => resolveRef(ref, values));
let res = '';
for (let i = 0; i < refValues.length; i++) {
var _a = parse(str), strings = _a.strings, rawRefs = _a.rawRefs;
var refValues = rawRefs.map(function (ref) { return resolveRef(ref, values); });
var res = '';
for (var i = 0; i < refValues.length; i++) {
res += strings[i];

@@ -17,6 +17,6 @@ res += refValues[i];

config = Object.assign({}, config);
for (let key in config) {
const value = config[key];
for (var key in config) {
var value = config[key];
if (typeof value === 'string') {
config[key] = resolveRefString(value, { env });
config[key] = resolveRefString(value, { env: env });
}

@@ -31,7 +31,8 @@ else if (typeof value === 'object') {

function getUsedEnvs(config) {
const result = {};
const traverse = val => {
var result = {};
var traverse = function (val) {
if (typeof val === 'string') {
const rawRefs = parse(val).rawRefs;
for (let ref of rawRefs) {
var rawRefs = parse(val).rawRefs;
for (var _i = 0, rawRefs_1 = rawRefs; _i < rawRefs_1.length; _i++) {
var ref = rawRefs_1[_i];
result[parseRef(ref).ref] = resolveRef(ref, {}, false);

@@ -41,3 +42,3 @@ }

else if (typeof val === 'object') {
for (let key in config) {
for (var key in config) {
traverse(config[key]);

@@ -52,15 +53,17 @@ }

function parseRef(rawRef) {
const [type, ref] = rawRef.split(/\s*:\s*/);
return { type, ref };
var _a = rawRef.split(/\s*:\s*/), type = _a[0], ref = _a[1];
return { type: type, ref: ref };
}
function resolveRef(rawRef, values = {}, throwIfUndef = true) {
const { type, ref } = parseRef(rawRef);
function resolveRef(rawRef, values, throwIfUndef) {
if (values === void 0) { values = {}; }
if (throwIfUndef === void 0) { throwIfUndef = true; }
var _a = parseRef(rawRef), type = _a.type, ref = _a.ref;
if (type === 'env') {
if (!ref) {
throw new Error(`Reference value is not present for ${type}: ${rawRef}`);
throw new Error("Reference value is not present for " + type + ": " + rawRef);
}
const refValue = values.env && values.env[ref] || process.env[ref];
var refValue = values.env && values.env[ref] || process.env[ref];
if (!refValue) {
if (throwIfUndef) {
throw new Error(`Environment variable ${ref} is not set`);
throw new Error("Environment variable " + ref + " is not set");
}

@@ -79,7 +82,7 @@ else {

function parse(str) {
const regex = /\${([^}]*)}/g;
const strings = [];
const rawRefs = [];
let prevIdx = 0;
let match;
var regex = /\${([^}]*)}/g;
var strings = [];
var rawRefs = [];
var prevIdx = 0;
var match;
// tslint:disable-next-line:no-conditional-assignment

@@ -95,3 +98,3 @@ while ((match = regex.exec(str)) !== null) {

strings.push(str.substring(prevIdx));
return { strings, rawRefs };
return { strings: strings, rawRefs: rawRefs };
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const path_1 = require("path");
const fs_1 = require("fs");
const errors_1 = require("./errors");
const GRAPHQL_CONFIG_NAME = '.graphqlconfig';
const GRAPHQL_CONFIG_YAML_NAME = '.graphqlconfig.yaml';
var path_1 = require("path");
var fs_1 = require("fs");
var errors_1 = require("./errors");
var GRAPHQL_CONFIG_NAME = '.graphqlconfig';
var GRAPHQL_CONFIG_YAML_NAME = '.graphqlconfig.yaml';
function isRootDir(path) {

@@ -17,5 +17,5 @@ return path_1.dirname(path) === path;

}
let currentDir = filePath;
var currentDir = filePath;
while (!isRootDir(currentDir)) {
const configPath = path_1.join(currentDir, GRAPHQL_CONFIG_NAME);
var configPath = path_1.join(currentDir, GRAPHQL_CONFIG_NAME);
if (fs_1.existsSync(configPath)) {

@@ -29,5 +29,5 @@ return configPath;

}
throw new errors_1.ConfigNotFoundError(`'${GRAPHQL_CONFIG_NAME} file is not available in the provided config ` +
`directory: ${filePath}\nPlease check the config directory path and try again.`);
throw new errors_1.ConfigNotFoundError("'" + GRAPHQL_CONFIG_NAME + " file is not available in the provided config " +
("directory: " + filePath + "\nPlease check the config directory path and try again."));
}
exports.findGraphQLConfigFile = findGraphQLConfigFile;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("./utils");
const findGraphQLConfigFile_1 = require("./findGraphQLConfigFile");
const GraphQLConfig_1 = require("./GraphQLConfig");
function getGraphQLConfig(rootDir = process.cwd()) {
const configPath = findGraphQLConfigFile_1.findGraphQLConfigFile(rootDir);
const config = utils_1.readConfig(configPath);
var utils_1 = require("./utils");
var findGraphQLConfigFile_1 = require("./findGraphQLConfigFile");
var GraphQLConfig_1 = require("./GraphQLConfig");
function getGraphQLConfig(rootDir) {
if (rootDir === void 0) { rootDir = process.cwd(); }
var configPath = findGraphQLConfigFile_1.findGraphQLConfigFile(rootDir);
var config = utils_1.readConfig(configPath);
utils_1.validateConfig(config);

@@ -13,5 +14,6 @@ return new GraphQLConfig_1.GraphQLConfig(config, configPath);

exports.getGraphQLConfig = getGraphQLConfig;
function getGraphQLProjectConfig(rootDir, projectName = process.env.GRAPHQL_CONFIG_PROJECT) {
function getGraphQLProjectConfig(rootDir, projectName) {
if (projectName === void 0) { projectName = process.env.GRAPHQL_CONFIG_PROJECT; }
return getGraphQLConfig(rootDir).getProjectConfig(projectName);
}
exports.getGraphQLProjectConfig = getGraphQLProjectConfig;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const path_1 = require("path");
const utils_1 = require("./utils");
const GraphQLProjectConfig_1 = require("./GraphQLProjectConfig");
class GraphQLConfig {
constructor(config, configPath) {
var path_1 = require("path");
var utils_1 = require("./utils");
var GraphQLProjectConfig_1 = require("./GraphQLProjectConfig");
var GraphQLConfig = (function () {
function GraphQLConfig(config, configPath) {
utils_1.validateConfig(config);

@@ -13,25 +13,26 @@ this.config = config;

}
getProjectConfig(projectName) {
GraphQLConfig.prototype.getProjectConfig = function (projectName) {
return new GraphQLProjectConfig_1.GraphQLProjectConfig(this.config, this.configPath, projectName);
}
getConfigForFile(filePath) {
const { projects } = this.config;
};
GraphQLConfig.prototype.getConfigForFile = function (filePath) {
var projects = this.config.projects;
if (!projects || Object.keys(projects).length === 0) {
const config = new GraphQLProjectConfig_1.GraphQLProjectConfig(this.config, this.configPath, undefined);
var config = new GraphQLProjectConfig_1.GraphQLProjectConfig(this.config, this.configPath, undefined);
return config.includesFile(filePath) ? config : null;
}
return Object.values(this.getProjects()).find(project => project.includesFile(filePath)) || null;
}
getProjectNameForFile(filePath) {
const proj = this.getConfigForFile(filePath);
return Object.values(this.getProjects()).find(function (project) { return project.includesFile(filePath); }) || null;
};
GraphQLConfig.prototype.getProjectNameForFile = function (filePath) {
var proj = this.getConfigForFile(filePath);
return proj && proj.projectName || null;
}
getProjects() {
const result = {};
for (const projectName in (this.config.projects || {})) {
};
GraphQLConfig.prototype.getProjects = function () {
var result = {};
for (var projectName in (this.config.projects || {})) {
result[projectName] = this.getProjectConfig(projectName);
}
return result;
}
}
};
return GraphQLConfig;
}());
exports.GraphQLConfig = GraphQLConfig;

@@ -10,2 +10,29 @@ "use strict";

};
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 };
}
};
var __rest = (this && this.__rest) || function (s, e) {

@@ -21,11 +48,11 @@ var t = {};

Object.defineProperty(exports, "__esModule", { value: true });
const path_1 = require("path");
const graphql_1 = require("graphql");
const utils_1 = require("./utils");
const extensions_1 = require("./extensions");
var path_1 = require("path");
var graphql_1 = require("graphql");
var utils_1 = require("./utils");
var extensions_1 = require("./extensions");
/*
* this class can be used for simple usecases where there is no need in per-file API
*/
class GraphQLProjectConfig {
constructor(config, configPath, projectName) {
var GraphQLProjectConfig = (function () {
function GraphQLProjectConfig(config, configPath, projectName) {
utils_1.validateConfig(config);

@@ -37,6 +64,6 @@ this.config = loadProjectConfig(config, projectName);

}
resolveConfigPath(relativePath) {
GraphQLProjectConfig.prototype.resolveConfigPath = function (relativePath) {
return path_1.resolve(this.configDir, relativePath);
}
includesFile(filePath) {
};
GraphQLProjectConfig.prototype.includesFile = function (filePath) {
if (filePath.startsWith('file://')) {

@@ -48,41 +75,64 @@ filePath = filePath.substr(7);

!utils_1.matchesGlobs(filePath, this.exclude));
}
getSchema() {
};
GraphQLProjectConfig.prototype.getSchema = function () {
if (this.schemaPath) {
return utils_1.readSchema(this.resolveConfigPath(this.schemaPath));
}
throw new Error(`"schemaPath" is required but not provided in ${this.configPath}`);
}
resolveIntrospection() {
return __awaiter(this, void 0, void 0, function* () {
return utils_1.schemaToIntrospection(this.getSchema());
throw new Error("\"schemaPath\" is required but not provided in " + this.configPath);
};
GraphQLProjectConfig.prototype.resolveIntrospection = function () {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, utils_1.schemaToIntrospection(this.getSchema())];
});
});
}
getSchemaSDL() {
};
GraphQLProjectConfig.prototype.getSchemaSDL = function () {
return graphql_1.printSchema(this.getSchema());
}
// Getters
get schemaPath() {
return this.config.schemaPath ? this.resolveConfigPath(this.config.schemaPath) : null;
}
get include() {
return (this.config.include || []).map(utils_1.normalizeGlob);
}
get exclude() {
return (this.config.exclude || []).map(utils_1.normalizeGlob);
}
get extensions() {
return this.config.extensions || {};
}
/*
extension relatad helper functions
*/
get endpointExtension() {
return this.extensions.endpoint ?
new extensions_1.GraphQLEndpointExtension(this.extensions.endpoint, this.configPath) : null;
}
}
};
Object.defineProperty(GraphQLProjectConfig.prototype, "schemaPath", {
// Getters
get: function () {
return this.config.schemaPath ? this.resolveConfigPath(this.config.schemaPath) : null;
},
enumerable: true,
configurable: true
});
Object.defineProperty(GraphQLProjectConfig.prototype, "include", {
get: function () {
return (this.config.include || []).map(utils_1.normalizeGlob);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GraphQLProjectConfig.prototype, "exclude", {
get: function () {
return (this.config.exclude || []).map(utils_1.normalizeGlob);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GraphQLProjectConfig.prototype, "extensions", {
get: function () {
return this.config.extensions || {};
},
enumerable: true,
configurable: true
});
Object.defineProperty(GraphQLProjectConfig.prototype, "endpointExtension", {
/*
extension relatad helper functions
*/
get: function () {
return this.extensions.endpoint ?
new extensions_1.GraphQLEndpointExtension(this.extensions.endpoint, this.configPath) : null;
},
enumerable: true,
configurable: true
});
return GraphQLProjectConfig;
}());
exports.GraphQLProjectConfig = GraphQLProjectConfig;
function loadProjectConfig(config, projectName) {
const { projects } = config, configBase = __rest(config, ["projects"]);
var projects = config.projects, configBase = __rest(config, ["projects"]);
if (projects == null || !Object.keys(projects).length) {

@@ -94,7 +144,7 @@ return config;

}
const projectConfig = projects[projectName];
var projectConfig = projects[projectName];
if (!projectConfig) {
throw new Error(`No config for ${projectName}`);
throw new Error("No config for " + projectName);
}
return utils_1.mergeConfigs(configBase, projectConfig);
}
"use strict";
var __assign = (this && this.__assign) || Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

@@ -10,12 +18,39 @@ return new (P || (P = Promise))(function (resolve, reject) {

};
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 });
const fs_1 = require("fs");
const path_1 = require("path");
const minimatch = require("minimatch");
const yaml = require("js-yaml");
const graphql_1 = require("graphql");
var fs_1 = require("fs");
var path_1 = require("path");
var minimatch = require("minimatch");
var yaml = require("js-yaml");
var graphql_1 = require("graphql");
function readConfig(configPath) {
let config;
var config;
try {
const rawConfig = fs_1.readFileSync(configPath, 'utf-8');
var rawConfig = fs_1.readFileSync(configPath, 'utf-8');
if (configPath.endsWith('.yaml')) {

@@ -29,3 +64,3 @@ config = yaml.safeLoad(rawConfig);

catch (error) {
error.message = `Parsing ${configPath} file has failed.\n` + error.message;
error.message = "Parsing " + configPath + " file has failed.\n" + error.message;
throw error;

@@ -44,3 +79,3 @@ }

function matchesGlobs(filePath, globs) {
return (globs || []).some(glob => minimatch(filePath, glob, { matchBase: true }));
return (globs || []).some(function (glob) { return minimatch(filePath, glob, { matchBase: true }); });
}

@@ -53,8 +88,8 @@ exports.matchesGlobs = matchesGlobs;

function mergeConfigs(dest, src) {
const result = Object.assign({}, dest, src);
var result = __assign({}, dest, src);
if (dest.extensions && src.extensions) {
result.extensions = Object.assign({}, dest.extensions, src.extensions);
result.extensions = __assign({}, dest.extensions, src.extensions);
}
if (dest.projects && src.projects) {
result.projects = Object.assign({}, dest.projects, src.projects);
result.projects = __assign({}, dest.projects, src.projects);
}

@@ -79,3 +114,3 @@ return result;

function readSchema(path) {
const data = fs_1.readFileSync(path, 'utf-8');
var data = fs_1.readFileSync(path, 'utf-8');
// FIXME: prefix error

@@ -86,3 +121,3 @@ switch (path_1.extname(path)) {

case '.json':
const introspection = JSON.parse(data);
var introspection = JSON.parse(data);
return valueToSchema(introspection);

@@ -107,19 +142,30 @@ default:

function writeSchema(path, schema) {
return __awaiter(this, void 0, void 0, function* () {
schema = valueToSchema(schema);
let data;
switch (path_1.extname(path)) {
case '.graphql':
data = graphql_1.printSchema(schema);
break;
case '.json':
const introspection = yield schemaToIntrospection(schema);
data = JSON.stringify(introspection, null, 2);
break;
default:
throw new Error('Unsupported schema file extention. Only ".graphql" and ".json" are supported');
}
fs_1.writeFileSync(path, data, 'utf-8');
return __awaiter(this, void 0, void 0, function () {
var data, _a, introspection;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
schema = valueToSchema(schema);
_a = path_1.extname(path);
switch (_a) {
case '.graphql': return [3 /*break*/, 1];
case '.json': return [3 /*break*/, 2];
}
return [3 /*break*/, 4];
case 1:
data = graphql_1.printSchema(schema);
return [3 /*break*/, 5];
case 2: return [4 /*yield*/, schemaToIntrospection(schema)];
case 3:
introspection = _b.sent();
data = JSON.stringify(introspection, null, 2);
return [3 /*break*/, 5];
case 4: throw new Error('Unsupported schema file extention. Only ".graphql" and ".json" are supported');
case 5:
fs_1.writeFileSync(path, data, 'utf-8');
return [2 /*return*/];
}
});
});
}
exports.writeSchema = writeSchema;
{
"name": "graphql-config",
"version": "1.0.0-rc.1",
"version": "1.0.0-rc.2",
"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",

# graphql-config
> The README reflects new [graphql-config protocol](specification.md).
> Old graphql-config-parser documentation [can be found here](https://github.com/graphcool/graphql-config/tree/graphql-config-parser)
The easiest way to configure your development environment with your GraphQL schema (supported by most tools, editors &amp; IDEs)

@@ -51,2 +54,6 @@

> Note: exclude and include fields are globs that should match filename.
> So, just `temp` or `temp/` won't match all files inside the directory.
> That's why the example uses `temp/**`
#### Specifying endpoint info

@@ -98,3 +105,3 @@

"prod": {
"url": "https://your-app.com/graphql"
"url": "https://your-app.com/graphql",
"subscription": {

@@ -126,7 +133,7 @@ "url": "wss://subscriptions.graph.cool/v1/instagram"

![](resources/how-it-works.png)
## `graphql-config` API [![Build Status](https://travis-ci.org/graphcool/graphql-config.svg?branch=master)](https://travis-ci.org/graphcool/graphql-config) [![npm version](https://badge.fury.io/js/graphql-config.svg)](https://badge.fury.io/js/graphql-config)
> **WIP: More examples are coming soon**
### getGraphQLProjectConfig

@@ -142,10 +149,5 @@

const config = getGraphQLProjectConfig()
config.resolveSchema()
.then(schema => {
// use schema for your tool/plugin
})
.catch((err) => {
console.error(err)
})
const config = getGraphQLProjectConfig('./optionalProjectDir', 'optionalProjectName')
const schema = config.getSchema()
// use schema for your tool/plugin
```

@@ -161,11 +163,5 @@

const config = getGraphQLConfig()
config.getConfigForFile(filename)
.resolveSchema()
.then(schema => {
// use schema for your tool/plugin
})
.catch((err) => {
console.error(err)
})
const config = getGraphQLConfig('./optionalProjectDir')
const schema = config.getConfigForFile(filename).getSchema()
// use schema for your tool/plugin
```

@@ -172,0 +168,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc