Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

graphql-config

Package Overview
Dependencies
Maintainers
10
Versions
320
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 3.0.0-alpha.5 to 3.0.0-alpha.6

dist/index.es.js

0

dist/config.d.ts

@@ -0,0 +0,0 @@ import { GraphQLCofigResult } from './types';

@@ -0,0 +0,0 @@ export declare class ConfigNotFoundError extends Error {

12

dist/extension.d.ts

@@ -0,3 +1,3 @@

import { SchemaPointerSingle, DocumentPointerSingle } from '@graphql-toolkit/common';
import { LoadersRegistry } from './loaders';
import { SchemaPointerSingle, DocumentPointerSingle } from './types';
export declare type GraphQLExtensionDeclaration = (api: ExtensionAPI) => GraphQLConfigExtension;

@@ -17,10 +17,4 @@ export interface ExtensionAPI {

readonly loaders: {
schema: LoadersRegistry<string | {
[url: string]: {
headers?: {
[headerName: string]: string;
} | undefined;
};
} | import("./types").PointerWithConfiguration<any>>;
documents: LoadersRegistry<import("./types").SchemaLocalPathPointer>;
schema: LoadersRegistry<string>;
documents: LoadersRegistry<string>;
};

@@ -27,0 +21,0 @@ register(extensionFn: GraphQLExtensionDeclaration): void;

@@ -6,1 +6,2 @@ import { IGraphQLConfig, IGraphQLProject, IGraphQLProjects, GraphQLCofigResult } from './types';

export declare function findConfig(rootDir?: string): Promise<GraphQLCofigResult>;
export declare function flatten<T>(arr: T[]): T extends (infer A)[] ? A[] : T[];
export { GraphQLConfig, loadConfig } from './config';
export { GraphQLProjectConfig } from './project-config';
export { GraphQLExtensionDeclaration } from './extension';
export { Source, SchemaLoader, DocumentLoader, UniversalLoader } from './loaders';
export { SchemaLoader, DocumentLoader, UniversalLoader } from './loaders';
export * from './types';
export * from './errors';

@@ -1,11 +0,639 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var config_1 = require("./config");
exports.GraphQLConfig = config_1.GraphQLConfig;
exports.loadConfig = config_1.loadConfig;
var project_config_1 = require("./project-config");
exports.GraphQLProjectConfig = project_config_1.GraphQLProjectConfig;
var loaders_1 = require("./loaders");
exports.Source = loaders_1.Source;
tslib_1.__exportStar(require("./errors"), exports);
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
function _interopNamespace(e) {
if (e && e.__esModule) { return e; } else {
var n = {};
if (e) {
Object.keys(e).forEach(function (k) {
var d = Object.getOwnPropertyDescriptor(e, k);
Object.defineProperty(n, k, d.get ? d : {
enumerable: true,
get: function () {
return e[k];
}
});
});
}
n['default'] = e;
return n;
}
}
const path = require('path');
const graphql = require('graphql');
const schemaMerging = require('@graphql-toolkit/schema-merging');
const minimatch = _interopDefault(require('minimatch'));
const cosmiconfig = _interopDefault(require('cosmiconfig'));
const graphqlFileLoader = require('@graphql-toolkit/graphql-file-loader');
const urlLoader = require('@graphql-toolkit/url-loader');
const jsonFileLoader = require('@graphql-toolkit/json-file-loader');
const common = require('@graphql-toolkit/common');
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/* global Reflect, Promise */
var extendStatics = function(d, b) {
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 extendStatics(d, b);
};
function __extends(d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
}
var __assign = function() {
__assign = Object.assign || function __assign(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;
};
return __assign.apply(this, arguments);
};
function __awaiter(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());
});
}
function __generator(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 = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, 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 ConfigNotFoundError = /** @class */ (function (_super) {
__extends(ConfigNotFoundError, _super);
function ConfigNotFoundError(message) {
var _this = _super.call(this, message) || this;
_this.name = _this.constructor.name;
_this.message = message;
return _this;
}
return ConfigNotFoundError;
}(Error));
var ConfigEmptyError = /** @class */ (function (_super) {
__extends(ConfigEmptyError, _super);
function ConfigEmptyError(message) {
var _this = _super.call(this, message) || this;
_this.name = _this.constructor.name;
_this.message = message;
return _this;
}
return ConfigEmptyError;
}(Error));
var ConfigInvalidError = /** @class */ (function (_super) {
__extends(ConfigInvalidError, _super);
function ConfigInvalidError(message) {
var _this = _super.call(this, message) || this;
_this.name = _this.constructor.name;
_this.message = message;
return _this;
}
return ConfigInvalidError;
}(Error));
var ProjectNotFoundError = /** @class */ (function (_super) {
__extends(ProjectNotFoundError, _super);
function ProjectNotFoundError(message) {
var _this = _super.call(this, message) || this;
_this.name = _this.constructor.name;
_this.message = message;
return _this;
}
return ProjectNotFoundError;
}(Error));
var LoadersMissingError = /** @class */ (function (_super) {
__extends(LoadersMissingError, _super);
function LoadersMissingError(message) {
var _this = _super.call(this, message) || this;
_this.name = _this.constructor.name;
_this.message = message;
return _this;
}
return LoadersMissingError;
}(Error));
var LoaderNoResultError = /** @class */ (function (_super) {
__extends(LoaderNoResultError, _super);
function LoaderNoResultError(message) {
var _this = _super.call(this, message) || this;
_this.name = _this.constructor.name;
_this.message = message;
return _this;
}
return LoaderNoResultError;
}(Error));
var ExtensionMissingError = /** @class */ (function (_super) {
__extends(ExtensionMissingError, _super);
function ExtensionMissingError(message) {
var _this = _super.call(this, message) || this;
_this.name = _this.constructor.name;
_this.message = message;
return _this;
}
return ExtensionMissingError;
}(Error));
function composeMessage() {
var lines = [];
for (var _i = 0; _i < arguments.length; _i++) {
lines[_i] = arguments[_i];
}
return lines.join('\n');
}
var cwd = typeof process !== 'undefined' ? process.cwd() : undefined;
function isMultipleProjectConfig(config) {
return typeof config.projects === 'object';
}
function isSingleProjectConfig(config) {
return typeof config.schema !== 'undefined';
}
function getConfig(filepath) {
return __awaiter(this, void 0, void 0, function () {
var result;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!filepath) {
throw new Error("Defining a file path is required");
}
return [4 /*yield*/, createCosmiConfig().load(filepath)];
case 1:
result = _a.sent();
if (!result) {
throw new ConfigNotFoundError(composeMessage("GraphQL Config file is not available: " + filepath, "Please check the config filepath."));
}
if (result.isEmpty) {
throw new ConfigEmptyError(composeMessage("GraphQL Config file is empty.", "Please check " + result.filepath));
}
return [2 /*return*/, {
config: result.config,
filepath: result.filepath,
}];
}
});
});
}
function findConfig(rootDir) {
if (rootDir === void 0) { rootDir = cwd; }
return __awaiter(this, void 0, void 0, function () {
var result;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!rootDir) {
throw new Error("Defining a root directiry is required");
}
return [4 /*yield*/, createCosmiConfig().search(rootDir)];
case 1:
result = _a.sent();
if (!result) {
throw new ConfigNotFoundError(composeMessage("GraphQL Config file is not available in the provided config directory: " + rootDir, "Please check the config directory."));
}
if (result.isEmpty) {
throw new ConfigEmptyError(composeMessage("GraphQL Config file is empty.", "Please check " + result.filepath));
}
return [2 /*return*/, {
config: result.config,
filepath: result.filepath,
}];
}
});
});
}
function replaceEnv(content) {
// https://regex101.com/r/sRTYo9/1
// Yes:
// ${NAME:DEFAULT}
// ${NAME}
// Not:
// ${NAME:}
var R = /\$\{([A-Z0-9_]+(\:[^\:]+)?)\}/gi;
return content.replace(R, function (_, result) {
var _a = result.split(':'), name = _a[0], value = _a[1];
return process.env[name] ? String(process.env[name]) : value;
});
}
function transformContent(content) {
return replaceEnv(content);
}
var cosmi = cosmiconfig;
var createCustomLoader = function (loader) {
return {
sync: function (filepath, content) {
return loader(filepath, transformContent(content));
},
async: function (filepath, content) {
return loader(filepath, transformContent(content));
},
};
};
var loadYaml = createCustomLoader(cosmi.loadYaml);
var loadJson = createCustomLoader(cosmi.loadJson);
function createCosmiConfig() {
// We need to wrap loaders in order to access and transform file content (as string)
// Cosmiconfig has transform option but at this point config is not a string but an object
return cosmiconfig('graphql', {
loaders: {
'.js': { sync: cosmi.loadJs, async: cosmi.loadJs },
'.json': loadJson,
'.yaml': loadYaml,
'.yml': loadYaml,
noExt: loadYaml,
},
});
}
function flatten(arr) {
var _a;
return (_a = Array.prototype).concat.apply(_a, arr);
}
function pick(key, items) {
return items.map(function (item) { return item[key]; });
}
var GraphQLProjectConfig = /** @class */ (function () {
function GraphQLProjectConfig(_a) {
var filepath = _a.filepath, name = _a.name, config = _a.config, extensionsRegistry = _a.extensionsRegistry;
this.filepath = filepath;
this.dirpath = path.dirname(filepath);
this.name = name;
this.extensions = config.extensions || {};
this.schema = config.schema;
this.documents = config.documents;
this._extensionsRegistry = extensionsRegistry;
}
GraphQLProjectConfig.prototype.hasExtension = function (name) {
return !!this.extensions[name];
};
GraphQLProjectConfig.prototype.extension = function (name) {
var extension = this._extensionsRegistry.get(name);
if (!extension) {
throw new ExtensionMissingError("Project " + this.name + " is missing " + name + " extension");
}
return __assign(__assign({}, this.extensions[name]), { schema: this.schema, documents: this.documents });
};
GraphQLProjectConfig.prototype.getSchema = function (out) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this.loadSchema(this.schema, out)];
});
});
};
GraphQLProjectConfig.prototype.getDocuments = function () {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
if (!this.documents) {
return [2 /*return*/, []];
}
return [2 /*return*/, this.loadDocuments(this.documents)];
});
});
};
GraphQLProjectConfig.prototype.loadSchema = function (pointer, out) {
return __awaiter(this, void 0, void 0, function () {
var schema, schemas, _a, _b, _c;
var _this = this;
return __generator(this, function (_d) {
switch (_d.label) {
case 0:
if (!Array.isArray(pointer)) return [3 /*break*/, 2];
return [4 /*yield*/, Promise.all(pointer.map(function (_pointer) {
return _this._extensionsRegistry.loaders.schema.load(_pointer);
}))];
case 1:
schemas = _d.sent();
schema = schemaMerging.mergeTypeDefs(pick('document', flatten(schemas)));
return [3 /*break*/, 4];
case 2:
_a = schemaMerging.mergeTypeDefs;
_b = pick;
_c = ['document'];
return [4 /*yield*/, this._extensionsRegistry.loaders.schema.load(pointer)];
case 3:
schema = _a.apply(void 0, [_b.apply(void 0, _c.concat([_d.sent()]))]);
_d.label = 4;
case 4:
if (out === 'DocumentNode') {
return [2 /*return*/, schema];
}
return [2 /*return*/, graphql.buildASTSchema(schema)];
}
});
});
};
GraphQLProjectConfig.prototype.loadDocuments = function (pointer) {
return __awaiter(this, void 0, void 0, function () {
var _a;
var _this = this;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
if (!pointer) {
return [2 /*return*/, []];
}
if (!Array.isArray(pointer)) return [3 /*break*/, 2];
_a = flatten;
return [4 /*yield*/, Promise.all(pointer.map(function (_pointer) {
return _this._extensionsRegistry.loaders.documents.load(_pointer);
}))];
case 1: return [2 /*return*/, _a.apply(void 0, [_b.sent()])];
case 2: return [2 /*return*/, this._extensionsRegistry.loaders.documents.load(pointer)];
}
});
});
};
GraphQLProjectConfig.prototype.match = function (filepath) {
var _this = this;
return [this.schema, this.documents].some(function (pointer) {
return match(filepath, _this.dirpath, pointer);
});
};
return GraphQLProjectConfig;
}());
// XXX: it works but uses nodejs - expose normalization of file and dir paths in config
function match(filepath, dirpath, pointer) {
if (!pointer) {
return false;
}
if (Array.isArray(pointer)) {
return pointer.some(function (p) { return match(filepath, dirpath, p); });
}
if (typeof pointer === 'string') {
var normalizedFilepath = path.normalize(path.isAbsolute(filepath) ? path.relative(dirpath, filepath) : filepath);
return minimatch(normalizedFilepath, path.normalize(pointer));
}
if (typeof pointer === 'object') {
return match(filepath, dirpath, Object.keys(pointer)[0]);
}
return false;
}
function isGlob(pointer) {
return typeof pointer === 'string' && pointer.includes('*');
}
function isPointerWithConfiguration(pointer) {
var isObject = typeof pointer === 'object';
var hasOneKey = Object.keys(pointer).length === 1;
var key = Object.keys(pointer)[0];
var hasConfiguration = typeof pointer[key] === 'object';
return isObject && hasOneKey && hasConfiguration;
}
function isSourceArray(sources) {
return Array.isArray(sources);
}
var LoadersRegistry = /** @class */ (function () {
function LoadersRegistry() {
this._loaders = [
new graphqlFileLoader.GraphQLFileLoader(),
new urlLoader.UrlLoader(),
new jsonFileLoader.JsonFileLoader(),
];
}
LoadersRegistry.prototype.register = function (loader) {
if (!this._loaders.some(function (l) { return l.loaderId() === loader.loaderId(); })) {
this._loaders.push(loader);
}
};
LoadersRegistry.prototype.load = function (pointer, options) {
return __awaiter(this, void 0, void 0, function () {
var globby, filepaths, results, key, _i, _a, loader, result;
var _this = this;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
if (!options) {
options = {};
}
if (!isGlob(pointer)) return [3 /*break*/, 4];
return [4 /*yield*/, new Promise(function (resolve) { resolve(_interopNamespace(require('globby'))); })];
case 1:
globby = (_b.sent()).default;
return [4 /*yield*/, globby(pointer)];
case 2:
filepaths = _b.sent();
return [4 /*yield*/, Promise.all(filepaths.map(function (filepath) { return _this.load(filepath, options); }))];
case 3:
results = _b.sent();
return [2 /*return*/, flatten(results.filter(isSourceArray))];
case 4:
if (isPointerWithConfiguration(pointer)) {
key = Object.keys(pointer)[0];
return [2 /*return*/, this.load(key, pointer[key])];
}
if (this._loaders.length === 0) {
throw new LoadersMissingError("Loaders are missing");
}
_i = 0, _a = this._loaders;
_b.label = 5;
case 5:
if (!(_i < _a.length)) return [3 /*break*/, 9];
loader = _a[_i];
return [4 /*yield*/, loader.canLoad(pointer, options)];
case 6:
if (!_b.sent()) return [3 /*break*/, 8];
return [4 /*yield*/, loader.load(pointer, options)];
case 7:
result = _b.sent();
if (result) {
return [2 /*return*/, [result]];
}
_b.label = 8;
case 8:
_i++;
return [3 /*break*/, 5];
case 9: throw new LoaderNoResultError("None of provided loaders could resolve: " + pointer);
}
});
});
};
return LoadersRegistry;
}());
var GraphQLExtensionsRegistry = /** @class */ (function () {
function GraphQLExtensionsRegistry() {
this._extensions = {};
this.loaders = {
schema: new LoadersRegistry(),
documents: new LoadersRegistry(),
};
}
GraphQLExtensionsRegistry.prototype.register = function (extensionFn) {
var extension = extensionFn({
logger: {},
loaders: this.loaders,
});
this._extensions[extension.name] = extension;
};
GraphQLExtensionsRegistry.prototype.has = function (extensionName) {
return !!this._extensions[extensionName];
};
GraphQLExtensionsRegistry.prototype.get = function (extensionName) {
return this._extensions[extensionName];
};
GraphQLExtensionsRegistry.prototype.names = function () {
return Object.keys(this._extensions);
};
GraphQLExtensionsRegistry.prototype.forEach = function (cb) {
for (var extensionName in this._extensions) {
cb(this._extensions[extensionName]);
}
};
return GraphQLExtensionsRegistry;
}());
var cwd$1 = typeof process !== 'undefined' ? process.cwd() : undefined;
function loadConfig(_a) {
var filepath = _a.filepath, _b = _a.rootDir, rootDir = _b === void 0 ? cwd$1 : _b, _c = _a.extensions, extensions = _c === void 0 ? [] : _c, _d = _a.throwOnMissing, throwOnMissing = _d === void 0 ? true : _d, _e = _a.throwOnEmpty, throwOnEmpty = _e === void 0 ? true : _e;
return __awaiter(this, void 0, void 0, function () {
var found, _f, error_1;
return __generator(this, function (_g) {
switch (_g.label) {
case 0:
_g.trys.push([0, 5, , 6]);
if (!filepath) return [3 /*break*/, 2];
return [4 /*yield*/, getConfig(filepath)];
case 1:
_f = _g.sent();
return [3 /*break*/, 4];
case 2: return [4 /*yield*/, findConfig(rootDir)];
case 3:
_f = _g.sent();
_g.label = 4;
case 4:
found = _f;
return [2 /*return*/, new GraphQLConfig(found, extensions)];
case 5:
error_1 = _g.sent();
if ((throwOnMissing && error_1 instanceof ConfigNotFoundError) ||
(throwOnEmpty && error_1 instanceof ConfigEmptyError)) {
return [2 /*return*/];
}
throw error_1;
case 6: return [2 /*return*/];
}
});
});
}
var GraphQLConfig = /** @class */ (function () {
function GraphQLConfig(raw, extensions) {
var _this = this;
this._rawConfig = raw.config;
this.filepath = raw.filepath;
this.dirpath = path.dirname(raw.filepath);
this.extensions = new GraphQLExtensionsRegistry();
extensions.forEach(function (extension) {
_this.extensions.register(extension);
});
this.projects = {};
if (isMultipleProjectConfig(this._rawConfig)) {
for (var projectName in this._rawConfig.projects) {
var config = this._rawConfig.projects[projectName];
this.projects[projectName] = new GraphQLProjectConfig({
filepath: this.filepath,
name: projectName,
config: config,
extensionsRegistry: this.extensions,
});
}
}
else if (isSingleProjectConfig(this._rawConfig)) {
this.projects['default'] = new GraphQLProjectConfig({
filepath: this.filepath,
name: 'default',
config: this._rawConfig,
extensionsRegistry: this.extensions,
});
}
}
GraphQLConfig.prototype.getProject = function (name) {
if (!name) {
return this.getDefault();
}
var project = this.projects[name];
if (!project) {
throw new ProjectNotFoundError("Project '" + name + "' not found");
}
return project;
};
GraphQLConfig.prototype.getProjectForFile = function (filepath) {
for (var projectName in this.projects) {
if (this.projects.hasOwnProperty(projectName)) {
var project = this.projects[projectName];
if (project.match(filepath)) {
return project;
}
}
}
throw new ProjectNotFoundError("File '" + filepath + "' doesn't match any project");
};
GraphQLConfig.prototype.getDefault = function () {
return this.getProject('default');
};
return GraphQLConfig;
}());
Object.defineProperty(exports, 'Source', {
enumerable: true,
get: function () {
return common.Source;
}
});
exports.ConfigEmptyError = ConfigEmptyError;
exports.ConfigInvalidError = ConfigInvalidError;
exports.ConfigNotFoundError = ConfigNotFoundError;
exports.ExtensionMissingError = ExtensionMissingError;
exports.GraphQLConfig = GraphQLConfig;
exports.GraphQLProjectConfig = GraphQLProjectConfig;
exports.LoaderNoResultError = LoaderNoResultError;
exports.LoadersMissingError = LoadersMissingError;
exports.ProjectNotFoundError = ProjectNotFoundError;
exports.composeMessage = composeMessage;
exports.loadConfig = loadConfig;
//# sourceMappingURL=index.js.map

@@ -1,16 +0,6 @@

import { DocumentNode } from 'graphql';
import { SchemaPointerSingle, DocumentPointerSingle } from './types';
export declare class Source {
document: DocumentNode;
location?: string;
constructor({ document, location, }: {
document: DocumentNode;
location?: string;
});
}
export declare type Loader<TPointer, TOptions = any> = (pointer: TPointer, options?: TOptions) => Promise<Source | void>;
import { Source, Loader, DocumentPointerSingle, SchemaPointerSingle } from '@graphql-toolkit/common';
export declare type SchemaLoader = Loader<SchemaPointerSingle>;
export declare type DocumentLoader = Loader<DocumentPointerSingle>;
export declare type UniversalLoader = Loader<SchemaPointerSingle | DocumentPointerSingle>;
export declare class LoadersRegistry<TPointer> {
export declare class LoadersRegistry<TPointer extends SchemaPointerSingle | DocumentPointerSingle> {
private _loaders;

@@ -17,0 +7,0 @@ register(loader: Loader<TPointer>): void;

import { GraphQLSchema, DocumentNode } from 'graphql';
import { Source } from '@graphql-toolkit/common';
import { GraphQLExtensionsRegistry } from './extension';
import { Source } from './loaders';
import { IExtensions, IGraphQLProject, SchemaPointer, DocumentPointer } from './types';

@@ -5,0 +5,0 @@ export declare class GraphQLProjectConfig {

@@ -1,20 +0,6 @@

declare type WithList<T> = T | T[];
declare type ElementOf<TList> = TList extends Array<infer TElement> ? TElement : never;
import { DocumentPointer, SchemaPointer } from '@graphql-toolkit/common';
export { DocumentPointer, SchemaPointer, Source } from '@graphql-toolkit/common';
export declare type PointerWithConfiguration<T = any> = {
[key: string]: T;
};
export declare type SchemaUrlPointer = string | {
[url: string]: {
headers?: {
[headerName: string]: string;
};
};
};
export declare type SchemaLocalPathPointer = string | PointerWithConfiguration;
export declare type SchemaGlobPathPointer = string | PointerWithConfiguration;
export declare type SchemaPointer = WithList<SchemaUrlPointer | SchemaLocalPathPointer | SchemaGlobPathPointer>;
export declare type SchemaPointerSingle = ElementOf<SchemaPointer>;
export declare type DocumentGlobPathPointer = string | PointerWithConfiguration;
export declare type DocumentPointer = WithList<DocumentGlobPathPointer>;
export declare type DocumentPointerSingle = ElementOf<DocumentPointer>;
export interface IExtensions {

@@ -36,2 +22,1 @@ [name: string]: any;

}
export {};
{
"name": "graphql-config",
"version": "3.0.0-alpha.5",
"version": "3.0.0-alpha.6",
"description": "The easiest way to configure your development environment with your GraphQL schema (supported by most tools, editors & IDEs)",
"main": "dist/index.js",
"module": "dist/index.es.js",
"typings": "dist/index.d.ts",

@@ -12,7 +13,8 @@ "sideEffects": false,

"prebuild": "yarn clean",
"build": "tsc",
"build": "rollup -c rollup.config.js",
"format": "prettier --write '{src,test}/**/*.{ts,graphql}'",
"lint": "eslint '{src,test}/**/*.ts'",
"test": "jest",
"precommit": "lint-staged"
"precommit": "lint-staged",
"release": "npm publish dist"
},

@@ -26,6 +28,10 @@ "files": [

"dependencies": {
"@graphql-toolkit/common": "0.6.1-alpha-c775427.3+c775427",
"@graphql-toolkit/graphql-file-loader": "0.6.1-alpha-c775427.3+c775427",
"@graphql-toolkit/json-file-loader": "0.6.1-alpha-c775427.3+c775427",
"@graphql-toolkit/schema-merging": "0.6.1-alpha-c775427.3+c775427",
"@graphql-toolkit/url-loader": "0.6.1-alpha-c775427.3+c775427",
"cosmiconfig": "5.2.1",
"globby": "10.0.1",
"graphql-toolkit": "0.5.17",
"lodash": "4.17.15"
"minimatch": "3.0.4"
},

@@ -35,3 +41,2 @@ "devDependencies": {

"@types/jest": "24.0.19",
"@types/lodash": "4.14.144",
"@types/nock": "11.1.0",

@@ -52,2 +57,5 @@ "@types/node": "12.11.1",

"rimraf": "3.0.0",
"rollup": "1.24.0",
"rollup-plugin-generate-package-json": "3.1.3",
"rollup-plugin-typescript2": "0.24.3",
"ts-jest": "24.1.0",

@@ -54,0 +62,0 @@ "tslib": "1.10.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