WIP - add extractor, generate snippet_data
This commit is contained in:
21
node_modules/graphql-config/LICENSE
generated
vendored
Normal file
21
node_modules/graphql-config/LICENSE
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016 Graphcool
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
192
node_modules/graphql-config/README.md
generated
vendored
Normal file
192
node_modules/graphql-config/README.md
generated
vendored
Normal file
@ -0,0 +1,192 @@
|
||||
# graphql-config
|
||||
|
||||
[](https://travis-ci.org/prisma/graphql-config) [](https://badge.fury.io/js/graphql-config)
|
||||
|
||||
> The README reflects the 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 & IDEs)
|
||||
|
||||
## Supported by...
|
||||
|
||||
### Language Services
|
||||
* [graphql-language-service](https://github.com/graphql/graphql-language-service) - An interface for building GraphQL language services for IDEs (_pending_)
|
||||
|
||||
### Editors
|
||||
* [js-graphql-intellij-plugin](https://github.com/jimkyndemeyer/js-graphql-intellij-plugin) - GraphQL language support for IntelliJ IDEA and WebStorm, including Relay.QL tagged templates in JavaScript and TypeScript (_pending_)
|
||||
* [atom-language-graphql](https://github.com/rmosolgo/language-graphql) - GraphQL support for Atom text editor (_pending_)
|
||||
* [vscode-graphql](https://github.com/stephen/vscode-graphql) - GraphQL support for VSCode text editor
|
||||
|
||||
### Tools
|
||||
|
||||
* [babel-plugin-react-relay](https://github.com/graphcool/babel-plugin-react-relay) - Babel compile step to process your `Relay.QL` queries (_pending_)
|
||||
* [babel-plugin-transform-relay-hot](https://github.com/nodkz/babel-plugin-transform-relay-hot) - Wrapper under BabelRelayPlugin with hot reload (_pending_)
|
||||
* [eslint-plugin-graphql](https://github.com/apollostack/eslint-plugin-graphql) - An ESLint plugin that checks tagged template strings against a GraphQL schema (_pending_)
|
||||
* [webpack-plugin-graphql-schema-hot](https://github.com/nodkz/webpack-plugin-graphql-schema-hot) - Webpack plugin which tracks changes in your schema and generates its introspection in `json` and `txt` formats (_pending_)
|
||||
|
||||
> Did we forget a tool/editor? Please [add it here](https://github.com/graphcool/graphql-config/issues/new).
|
||||
|
||||
**[Go to `graphql-config` library docs](#graphql-config-api)**
|
||||
|
||||
## Usage
|
||||
|
||||
**tl;dr**
|
||||
|
||||
Install [`graphql-cli`](https://github.com/graphcool/graphql-cli) and run `graphql init`. Answer a few simple questions and you are set up!
|
||||
|
||||
You can either configure your GraphQL endpoint via a configuration file `.graphqlconfig`
|
||||
(or `.graphqlconfig.yaml`) which should be put into the root of your project
|
||||
|
||||
### Simplest use case
|
||||
|
||||
The simplest config specifies only `schemaPath` which is path to the file with introspection
|
||||
results or corresponding SDL document
|
||||
|
||||
```json
|
||||
{
|
||||
"schemaPath": "schema.graphql"
|
||||
}
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
```json
|
||||
{
|
||||
"schemaPath": "schema.json"
|
||||
}
|
||||
```
|
||||
|
||||
### Specifying includes/excludes files
|
||||
|
||||
You can specify which files are included/excluded using the corresponding options:
|
||||
|
||||
```json
|
||||
{
|
||||
"schemaPath": "schema.graphql",
|
||||
"includes": ["*.graphql"],
|
||||
"excludes": ["temp/**"]
|
||||
}
|
||||
```
|
||||
|
||||
> Note: `excludes` and `includes` 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
|
||||
|
||||
You may specify your endpoints info in `.graphqlconfig` which may be used by some tools.
|
||||
The simplest case:
|
||||
|
||||
```json
|
||||
{
|
||||
"schemaPath": "schema.graphql",
|
||||
"extensions": {
|
||||
"endpoints": {
|
||||
"dev": "https://example.com/graphql"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
In case you need provide additional information, for example headers to authenticate your GraphQL endpoint or
|
||||
an endpoint for subscription, you can use expanded version:
|
||||
|
||||
```json
|
||||
{
|
||||
"schemaPath": "schema.graphql",
|
||||
"extensions": {
|
||||
"endpoints": {
|
||||
"dev": {
|
||||
"url": "https://example.com/graphql",
|
||||
"headers": {
|
||||
"Authorization": "Bearer ${env:AUTH_TOKEN_ENV}"
|
||||
},
|
||||
"subscription": {
|
||||
"url": "ws://example.com/graphql",
|
||||
"connectionParams": {
|
||||
"Token": "${env:YOUR_APP_TOKEN}"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
> Note: do not save secure information in .graphqlconfig file. Use [Environment variables](specification.md#referencing-environment-variables) for that like in the example above.
|
||||
|
||||
In case if you have multiple endpoints use the following syntax:
|
||||
|
||||
```json
|
||||
{
|
||||
"schemaPath": "schema.graphql",
|
||||
"extensions": {
|
||||
"endpoints": {
|
||||
"prod": {
|
||||
"url": "https://your-app.com/graphql",
|
||||
"subscription": {
|
||||
"url": "wss://subscriptions.graph.cool/v1/instagram"
|
||||
}
|
||||
},
|
||||
"dev": {
|
||||
"url": "http://localhost:3000/graphql",
|
||||
"subscription": {
|
||||
"url": "ws://localhost:3001"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Multi-project configuration (advanced)
|
||||
> TBD
|
||||
|
||||
__Refer to [specification use-cases](specification.md#use-cases) for details__
|
||||
|
||||
## How it works
|
||||
|
||||
This project aims to be provide a unifying configuration file format to configure your GraphQL schema in your development environment.
|
||||
|
||||
Additional to the format specification, it provides the [`graphql-config`](#graphql-config-api) library, which is used by [all supported tools and editor plugins](#supported-by). The library reads your provided configuration and passes the actual GraphQL schema along to the tool which called it.
|
||||
|
||||
|
||||
## `graphql-config` API
|
||||
|
||||
Here are very basic examples of how to use `graphql-config` library.
|
||||
|
||||
You can find **[the detailed documentation here](docs/)**
|
||||
|
||||
### getGraphQLProjectConfig
|
||||
|
||||
**NOTE:** if your tool works on per-file basis (e.g. editor plugin, linter, etc) use
|
||||
[`getGraphQLConfig`](#getGraphQLConfig) function
|
||||
|
||||
`getGraphQLProjectConfig` should be used by tools that do not work on per-file basis
|
||||
|
||||
```js
|
||||
import { getGraphQLProjectConfig } from 'graphql-config'
|
||||
|
||||
const config = getGraphQLProjectConfig('./optionalProjectDir', 'optionalProjectName')
|
||||
const schema = config.getSchema()
|
||||
// use schema for your tool/plugin
|
||||
```
|
||||
|
||||
### getGraphQLConfig
|
||||
|
||||
`getGraphQLConfig` should be used by tools that work on per-file basis (editor plugins,
|
||||
linters, etc.)
|
||||
|
||||
```js
|
||||
import { getGraphQLConfig } from 'graphql-config'
|
||||
|
||||
const config = getGraphQLConfig('./optionalProjectDir')
|
||||
const schema = config.getConfigForFile(filename).getSchema()
|
||||
// use schema for your tool/plugin
|
||||
```
|
||||
|
||||
## Help & Community [](https://slack.graph.cool)
|
||||
|
||||
Join our [Slack community](http://slack.graph.cool/) if you run into issues or have questions. We love talking to you!
|
||||
|
||||

|
||||
15
node_modules/graphql-config/lib/GraphQLConfig.d.ts
generated
vendored
Normal file
15
node_modules/graphql-config/lib/GraphQLConfig.d.ts
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
import { GraphQLConfigData } from './types';
|
||||
import { GraphQLProjectConfig } from './GraphQLProjectConfig';
|
||||
export declare class GraphQLConfig {
|
||||
config: GraphQLConfigData;
|
||||
configPath: string;
|
||||
constructor(config: GraphQLConfigData, configPath: string);
|
||||
readonly configDir: string;
|
||||
getProjectConfig(projectName?: string): GraphQLProjectConfig;
|
||||
getConfigForFile(filePath: string): GraphQLProjectConfig | undefined;
|
||||
getProjectNameForFile(filePath: string): string | undefined;
|
||||
getProjects(): {
|
||||
[name: string]: GraphQLProjectConfig;
|
||||
} | undefined;
|
||||
saveConfig(newConfig: GraphQLConfigData, projectName?: string): void;
|
||||
}
|
||||
60
node_modules/graphql-config/lib/GraphQLConfig.js
generated
vendored
Normal file
60
node_modules/graphql-config/lib/GraphQLConfig.js
generated
vendored
Normal file
@ -0,0 +1,60 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var path_1 = require("path");
|
||||
var utils_1 = require("./utils");
|
||||
var lodash_1 = require("lodash");
|
||||
var GraphQLProjectConfig_1 = require("./GraphQLProjectConfig");
|
||||
var GraphQLConfig = /** @class */ (function () {
|
||||
function GraphQLConfig(config, configPath) {
|
||||
utils_1.validateConfig(config);
|
||||
this.config = config;
|
||||
this.configPath = configPath;
|
||||
}
|
||||
Object.defineProperty(GraphQLConfig.prototype, "configDir", {
|
||||
get: function () {
|
||||
return path_1.dirname(this.configPath);
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
GraphQLConfig.prototype.getProjectConfig = function (projectName) {
|
||||
return new GraphQLProjectConfig_1.GraphQLProjectConfig(this.config, this.configPath, projectName);
|
||||
};
|
||||
GraphQLConfig.prototype.getConfigForFile = function (filePath) {
|
||||
var projects = this.config.projects;
|
||||
if (!projects || Object.keys(projects).length === 0) {
|
||||
var config = new GraphQLProjectConfig_1.GraphQLProjectConfig(this.config, this.configPath, undefined);
|
||||
return config.includesFile(filePath) ? config : undefined;
|
||||
}
|
||||
return lodash_1.values(this.getProjects()).find(function (project) { return project.includesFile(filePath); }) || undefined;
|
||||
};
|
||||
GraphQLConfig.prototype.getProjectNameForFile = function (filePath) {
|
||||
var proj = this.getConfigForFile(filePath);
|
||||
return proj && proj.projectName || undefined;
|
||||
};
|
||||
GraphQLConfig.prototype.getProjects = function () {
|
||||
var result = {};
|
||||
for (var projectName in (this.config.projects || {})) {
|
||||
result[projectName] = this.getProjectConfig(projectName);
|
||||
}
|
||||
if (Object.keys(result).length === 0) {
|
||||
return undefined;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
GraphQLConfig.prototype.saveConfig = function (newConfig, projectName) {
|
||||
var config;
|
||||
if (projectName) {
|
||||
config = this.config;
|
||||
config.projects = config.projects || {};
|
||||
config.projects[projectName] = config.projects[projectName] || {};
|
||||
config.projects[projectName] = newConfig;
|
||||
}
|
||||
else {
|
||||
config = newConfig;
|
||||
}
|
||||
utils_1.writeConfig(this.configPath, config);
|
||||
};
|
||||
return GraphQLConfig;
|
||||
}());
|
||||
exports.GraphQLConfig = GraphQLConfig;
|
||||
20
node_modules/graphql-config/lib/GraphQLProjectConfig.d.ts
generated
vendored
Normal file
20
node_modules/graphql-config/lib/GraphQLProjectConfig.d.ts
generated
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
import { GraphQLSchema } from 'graphql';
|
||||
import { IntrospectionResult, GraphQLResolvedConfigData, GraphQLConfigData, GraphQLConfigExtensions } from './types';
|
||||
import { GraphQLEndpointsExtension } from './extensions';
|
||||
export declare class GraphQLProjectConfig {
|
||||
config: GraphQLResolvedConfigData;
|
||||
configPath: string;
|
||||
projectName?: string;
|
||||
constructor(config: GraphQLConfigData, configPath: string, projectName?: string);
|
||||
resolveConfigPath(relativePath: string): string;
|
||||
includesFile(fileUri: string): boolean;
|
||||
getSchema(): GraphQLSchema;
|
||||
resolveIntrospection(): Promise<IntrospectionResult>;
|
||||
getSchemaSDL(): string;
|
||||
readonly configDir: string;
|
||||
readonly schemaPath: string | null;
|
||||
readonly includes: string[];
|
||||
readonly excludes: string[];
|
||||
readonly extensions: GraphQLConfigExtensions;
|
||||
readonly endpointsExtension: GraphQLEndpointsExtension | null;
|
||||
}
|
||||
163
node_modules/graphql-config/lib/GraphQLProjectConfig.js
generated
vendored
Normal file
163
node_modules/graphql-config/lib/GraphQLProjectConfig.js
generated
vendored
Normal file
@ -0,0 +1,163 @@
|
||||
"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 };
|
||||
}
|
||||
};
|
||||
var __rest = (this && this.__rest) || function (s, e) {
|
||||
var t = {};
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
||||
t[p] = s[p];
|
||||
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
||||
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)
|
||||
t[p[i]] = s[p[i]];
|
||||
return t;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
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
|
||||
*/
|
||||
var GraphQLProjectConfig = /** @class */ (function () {
|
||||
function GraphQLProjectConfig(config, configPath, projectName) {
|
||||
utils_1.validateConfig(config);
|
||||
this.config = loadProjectConfig(config, projectName);
|
||||
this.configPath = configPath;
|
||||
this.projectName = projectName;
|
||||
}
|
||||
GraphQLProjectConfig.prototype.resolveConfigPath = function (relativePath) {
|
||||
return path_1.resolve(this.configDir, relativePath);
|
||||
};
|
||||
GraphQLProjectConfig.prototype.includesFile = function (fileUri) {
|
||||
var filePath = fileUri.startsWith('file://') ?
|
||||
fileUri.substr(7) : fileUri;
|
||||
var fullFilePath = filePath.startsWith(this.configDir) ?
|
||||
filePath : path_1.resolve(path_1.join(this.configDir, filePath));
|
||||
var relativePath = path_1.relative(this.configDir, fullFilePath);
|
||||
return ((!this.config.includes ||
|
||||
utils_1.matchesGlobs(relativePath, this.configDir, this.includes)) && !utils_1.matchesGlobs(relativePath, this.configDir, this.excludes));
|
||||
};
|
||||
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);
|
||||
};
|
||||
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())];
|
||||
});
|
||||
});
|
||||
};
|
||||
GraphQLProjectConfig.prototype.getSchemaSDL = function () {
|
||||
return graphql_1.printSchema(this.getSchema());
|
||||
};
|
||||
Object.defineProperty(GraphQLProjectConfig.prototype, "configDir", {
|
||||
// Getters
|
||||
get: function () {
|
||||
return path_1.dirname(this.configPath);
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(GraphQLProjectConfig.prototype, "schemaPath", {
|
||||
get: function () {
|
||||
return this.config.schemaPath ? this.resolveConfigPath(this.config.schemaPath) : null;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(GraphQLProjectConfig.prototype, "includes", {
|
||||
get: function () {
|
||||
return (this.config.includes || []).map(utils_1.normalizeGlob);
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(GraphQLProjectConfig.prototype, "excludes", {
|
||||
get: function () {
|
||||
return (this.config.excludes || []).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, "endpointsExtension", {
|
||||
/*
|
||||
extension related helper functions
|
||||
*/
|
||||
get: function () {
|
||||
if (!this.extensions.endpoints) {
|
||||
return null;
|
||||
}
|
||||
var endpoints = this.extensions.endpoints;
|
||||
if (typeof endpoints !== 'object' || Array.isArray(endpoints)) {
|
||||
throw new Error(this.configPath + ": \"endpoints\" should be an object");
|
||||
}
|
||||
if (Object.keys(endpoints).length === 0) {
|
||||
return null;
|
||||
}
|
||||
return new extensions_1.GraphQLEndpointsExtension(this.extensions.endpoints, this.configPath);
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
return GraphQLProjectConfig;
|
||||
}());
|
||||
exports.GraphQLProjectConfig = GraphQLProjectConfig;
|
||||
function loadProjectConfig(config, projectName) {
|
||||
var projects = config.projects, configBase = __rest(config, ["projects"]);
|
||||
if (projects == null || !Object.keys(projects).length) {
|
||||
return config;
|
||||
}
|
||||
if (!projectName) {
|
||||
throw new Error("Project name must be specified for multiproject config. " +
|
||||
("Valid project names: " + Object.keys(projects).join(', ')));
|
||||
}
|
||||
var projectConfig = projects[projectName];
|
||||
if (!projectConfig) {
|
||||
throw new Error("\"" + projectName + "\" is not a valid project name. " +
|
||||
("Valid project names: " + Object.keys(projects).join(', ')));
|
||||
}
|
||||
return utils_1.mergeConfigs(configBase, projectConfig);
|
||||
}
|
||||
1
node_modules/graphql-config/lib/__tests__/basic/findGraphQLConfigFile.d.ts
generated
vendored
Normal file
1
node_modules/graphql-config/lib/__tests__/basic/findGraphQLConfigFile.d.ts
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
export {};
|
||||
19
node_modules/graphql-config/lib/__tests__/basic/findGraphQLConfigFile.js
generated
vendored
Normal file
19
node_modules/graphql-config/lib/__tests__/basic/findGraphQLConfigFile.js
generated
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var ava_1 = require("ava");
|
||||
var path_1 = require("path");
|
||||
var fs_1 = require("fs");
|
||||
var os_1 = require("os");
|
||||
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('returns a correct config filename for 1st level of sub directories', function (t) {
|
||||
var configFile = _1.findGraphQLConfigFile(__dirname + "/../sub-directory-config");
|
||||
t.deepEqual(configFile, path_1.join(__dirname + "/../sub-directory-config/sub-directory-2", '.graphqlconfig'));
|
||||
});
|
||||
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'));
|
||||
t.throws(function () { return _1.findGraphQLConfigFile(tempDir); }, _1.ConfigNotFoundError);
|
||||
});
|
||||
1
node_modules/graphql-config/lib/__tests__/basic/getGraphQLConfig.d.ts
generated
vendored
Normal file
1
node_modules/graphql-config/lib/__tests__/basic/getGraphQLConfig.d.ts
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
export {};
|
||||
39
node_modules/graphql-config/lib/__tests__/basic/getGraphQLConfig.js
generated
vendored
Normal file
39
node_modules/graphql-config/lib/__tests__/basic/getGraphQLConfig.js
generated
vendored
Normal file
@ -0,0 +1,39 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var ava_1 = require("ava");
|
||||
var path_1 = require("path");
|
||||
var graphql_1 = require("graphql");
|
||||
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', function (t) {
|
||||
var testWithSchemaConfig = config.getProjectConfig('testWithSchema');
|
||||
t.deepEqual(testWithSchemaConfig.projectName, 'testWithSchema');
|
||||
});
|
||||
ava_1.default('returns config for file', function (t) {
|
||||
var testWithSchemaConfig = config.getConfigForFile(path_1.resolve('./config/schema-a.graphql'));
|
||||
if (testWithSchemaConfig) {
|
||||
t.deepEqual(testWithSchemaConfig.projectName, 'testWithSchema');
|
||||
}
|
||||
else {
|
||||
t.fail();
|
||||
}
|
||||
});
|
||||
ava_1.default('returns a correct root dir', function (t) {
|
||||
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);
|
||||
});
|
||||
ava_1.default('reads single schema', function (t) {
|
||||
var typeDefs = "type Query {\n hello: String!\n}\n";
|
||||
t.is(graphql_1.printSchema(config.getProjectConfig('testSchemaA').getSchema()), typeDefs);
|
||||
});
|
||||
ava_1.default('reads imported schema', function (t) {
|
||||
var typeDefs = "type Query {\n hello: String!\n user: User!\n}\n\ntype User {\n name: String\n}\n";
|
||||
t.is(graphql_1.printSchema(config.getProjectConfig('testSchemaB').getSchema()), typeDefs);
|
||||
});
|
||||
1
node_modules/graphql-config/lib/__tests__/basic/getGraphQLProjectConfig.d.ts
generated
vendored
Normal file
1
node_modules/graphql-config/lib/__tests__/basic/getGraphQLProjectConfig.d.ts
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
export {};
|
||||
54
node_modules/graphql-config/lib/__tests__/basic/getGraphQLProjectConfig.js
generated
vendored
Normal file
54
node_modules/graphql-config/lib/__tests__/basic/getGraphQLProjectConfig.js
generated
vendored
Normal file
@ -0,0 +1,54 @@
|
||||
"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 };
|
||||
}
|
||||
};
|
||||
var _this = this;
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var ava_1 = require("ava");
|
||||
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.snapshot(resolvedSchema);
|
||||
return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
}); });
|
||||
1
node_modules/graphql-config/lib/__tests__/endpoint-extension/resolve.d.ts
generated
vendored
Normal file
1
node_modules/graphql-config/lib/__tests__/endpoint-extension/resolve.d.ts
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
export {};
|
||||
180
node_modules/graphql-config/lib/__tests__/endpoint-extension/resolve.js
generated
vendored
Normal file
180
node_modules/graphql-config/lib/__tests__/endpoint-extension/resolve.js
generated
vendored
Normal file
@ -0,0 +1,180 @@
|
||||
"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 };
|
||||
}
|
||||
};
|
||||
var _this = this;
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var ava_1 = require("ava");
|
||||
var graphql_1 = require("graphql");
|
||||
var _1 = require("../../");
|
||||
var utils_1 = require("../utils");
|
||||
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, endpoints;
|
||||
return __generator(this, function (_a) {
|
||||
configData = {
|
||||
schemaPath: '../schema.json',
|
||||
extensions: {
|
||||
endpoints: {
|
||||
dev: 'http://default',
|
||||
},
|
||||
},
|
||||
};
|
||||
config = new _1.GraphQLProjectConfig(configData, confPath);
|
||||
endpoints = config.endpointsExtension;
|
||||
t.deepEqual(endpoints && endpoints.getRawEndpointsMap(), {
|
||||
dev: { 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: {
|
||||
endpoints: {
|
||||
dev: {
|
||||
url: 'http://default',
|
||||
subscription: {
|
||||
url: 'ws://test',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
config = new _1.GraphQLProjectConfig(configData, confPath, undefined);
|
||||
endpoint = config.endpointsExtension;
|
||||
t.deepEqual(endpoint && endpoint.getRawEndpointsMap(), {
|
||||
dev: configData.extensions.endpoints.dev,
|
||||
});
|
||||
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: {
|
||||
endpoints: {
|
||||
dev: 'http://dev',
|
||||
prod: {
|
||||
url: 'http://prod',
|
||||
subscription: {
|
||||
url: 'ws://prod',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
config = new _1.GraphQLProjectConfig(configData, confPath, undefined);
|
||||
endpoint = config.endpointsExtension;
|
||||
t.deepEqual(endpoint && endpoint.getRawEndpointsMap(), {
|
||||
dev: {
|
||||
url: 'http://dev',
|
||||
},
|
||||
prod: {
|
||||
url: 'http://prod',
|
||||
subscription: {
|
||||
url: 'ws://prod',
|
||||
},
|
||||
},
|
||||
});
|
||||
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: {
|
||||
endpoints: {
|
||||
dev: {
|
||||
url: 'http://dev',
|
||||
subscription: {
|
||||
url: 'ws://dev',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
config = new _1.GraphQLProjectConfig(configData, confPath, undefined);
|
||||
endpoint = config.endpointsExtension;
|
||||
error = t.throws(function () { return endpoint && endpoint.getEndpoint('prod').resolveSchema(); });
|
||||
t.regex(error.message, /"prod" is not valid endpoint name. Valid endpoint names: dev/);
|
||||
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: {
|
||||
endpoints: {
|
||||
dev: 'http://127.0.0.1:33333',
|
||||
},
|
||||
},
|
||||
};
|
||||
config = new _1.GraphQLProjectConfig(configData, confPath, undefined);
|
||||
if (!config.endpointsExtension) {
|
||||
throw 'endpointExtension can\'t be empty';
|
||||
}
|
||||
return [4 /*yield*/, config.endpointsExtension
|
||||
.getEndpoint('dev')
|
||||
.resolveSchema()];
|
||||
case 1:
|
||||
schema = _a.sent();
|
||||
return [4 /*yield*/, graphql_1.graphql(schema, graphql_1.introspectionQuery)];
|
||||
case 2:
|
||||
resolvedIntrospection = _a.sent();
|
||||
t.snapshot(resolvedIntrospection);
|
||||
return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
}); });
|
||||
1
node_modules/graphql-config/lib/__tests__/endpoint-extension/string-refs.d.ts
generated
vendored
Normal file
1
node_modules/graphql-config/lib/__tests__/endpoint-extension/string-refs.d.ts
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
export {};
|
||||
113
node_modules/graphql-config/lib/__tests__/endpoint-extension/string-refs.js
generated
vendored
Normal file
113
node_modules/graphql-config/lib/__tests__/endpoint-extension/string-refs.js
generated
vendored
Normal file
@ -0,0 +1,113 @@
|
||||
"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 };
|
||||
}
|
||||
};
|
||||
var _this = this;
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var ava_1 = require("ava");
|
||||
var _1 = require("../../");
|
||||
var utils_1 = require("../utils");
|
||||
var endpoints;
|
||||
ava_1.default.beforeEach(function () {
|
||||
endpoints = _1.getGraphQLProjectConfig(__dirname)
|
||||
.endpointsExtension;
|
||||
});
|
||||
ava_1.default('getEndpointsMap', function (t) { return __awaiter(_this, void 0, void 0, function () {
|
||||
return __generator(this, function (_a) {
|
||||
t.deepEqual(endpoints.getRawEndpointsMap(), {
|
||||
default: {
|
||||
url: '${env:TEST_ENDPOINT_URL}',
|
||||
},
|
||||
});
|
||||
return [2 /*return*/];
|
||||
});
|
||||
}); });
|
||||
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(endpoints.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(endpoints.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 endpoints.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 endpoints
|
||||
.getEndpoint('default', { TEST_ENDPOINT_URL: 'http://127.0.0.1:33333' })
|
||||
.resolveSchema();
|
||||
});
|
||||
return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
}); });
|
||||
ava_1.default('getUsedEnvs', function (t) { return __awaiter(_this, void 0, void 0, function () {
|
||||
var configData, envs;
|
||||
return __generator(this, function (_a) {
|
||||
configData = {
|
||||
schemaPath: '../schema.json',
|
||||
extensions: {
|
||||
endpoints: {
|
||||
dev: 'http://127.0.0.1:${env:EXTENSION_TEST_PORT}',
|
||||
},
|
||||
},
|
||||
};
|
||||
envs = _1.getUsedEnvs(configData);
|
||||
t.is(Object.keys(envs)[0], 'EXTENSION_TEST_PORT');
|
||||
return [2 /*return*/];
|
||||
});
|
||||
}); });
|
||||
1
node_modules/graphql-config/lib/__tests__/introspection-query/getSchema.d.ts
generated
vendored
Normal file
1
node_modules/graphql-config/lib/__tests__/introspection-query/getSchema.d.ts
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
export {};
|
||||
10
node_modules/graphql-config/lib/__tests__/introspection-query/getSchema.js
generated
vendored
Normal file
10
node_modules/graphql-config/lib/__tests__/introspection-query/getSchema.js
generated
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var ava_1 = require("ava");
|
||||
var graphql_1 = require("graphql");
|
||||
var _1 = require("../../");
|
||||
ava_1.default('reads single schema', function (t) {
|
||||
var config = _1.getGraphQLConfig(__dirname);
|
||||
var typeDefs = "schema {\n query: RootQueryType\n}\n\ntype Bar {\n widgets: [Widget]\n}\n\ntype RootQueryType {\n foo: String\n bar: Bar\n}\n\ntype Widget {\n count: Int\n}\n";
|
||||
t.is(graphql_1.printSchema(config.getProjectConfig('testSchemaA').getSchema()), typeDefs);
|
||||
});
|
||||
1
node_modules/graphql-config/lib/__tests__/utils.d.ts
generated
vendored
Normal file
1
node_modules/graphql-config/lib/__tests__/utils.d.ts
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
export declare function serveSchema(port?: number): Promise<any>;
|
||||
16
node_modules/graphql-config/lib/__tests__/utils.js
generated
vendored
Normal file
16
node_modules/graphql-config/lib/__tests__/utils.js
generated
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
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));
|
||||
};
|
||||
var server = http_1.createServer(handleRequest);
|
||||
return new Promise(function (resolve) {
|
||||
server.listen(port, resolve);
|
||||
});
|
||||
}
|
||||
exports.serveSchema = serveSchema;
|
||||
1
node_modules/graphql-config/lib/__tests__/yaml/test.d.ts
generated
vendored
Normal file
1
node_modules/graphql-config/lib/__tests__/yaml/test.d.ts
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
export {};
|
||||
54
node_modules/graphql-config/lib/__tests__/yaml/test.js
generated
vendored
Normal file
54
node_modules/graphql-config/lib/__tests__/yaml/test.js
generated
vendored
Normal file
@ -0,0 +1,54 @@
|
||||
"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 };
|
||||
}
|
||||
};
|
||||
var _this = this;
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var ava_1 = require("ava");
|
||||
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(__dirname);
|
||||
return [4 /*yield*/, config.resolveIntrospection()];
|
||||
case 1:
|
||||
resolvedSchema = _a.sent();
|
||||
t.snapshot(resolvedSchema);
|
||||
return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
}); });
|
||||
4
node_modules/graphql-config/lib/errors.d.ts
generated
vendored
Normal file
4
node_modules/graphql-config/lib/errors.d.ts
generated
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
declare const ConfigNotFoundError_base: ErrorConstructor;
|
||||
export declare class ConfigNotFoundError extends ConfigNotFoundError_base {
|
||||
constructor(message: string);
|
||||
}
|
||||
31
node_modules/graphql-config/lib/errors.js
generated
vendored
Normal file
31
node_modules/graphql-config/lib/errors.js
generated
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
"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 });
|
||||
function ExtendableBuiltin(cls) {
|
||||
function ExtendableBuiltin() {
|
||||
cls.apply(this, arguments);
|
||||
}
|
||||
ExtendableBuiltin.prototype = Object.create(cls.prototype);
|
||||
Object.setPrototypeOf(ExtendableBuiltin, cls);
|
||||
return ExtendableBuiltin;
|
||||
}
|
||||
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;
|
||||
}(ExtendableBuiltin(Error)));
|
||||
exports.ConfigNotFoundError = ConfigNotFoundError;
|
||||
48
node_modules/graphql-config/lib/extensions/endpoints/EndpointsExtension.d.ts
generated
vendored
Normal file
48
node_modules/graphql-config/lib/extensions/endpoints/EndpointsExtension.d.ts
generated
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
import { GraphQLClient } from 'graphql-request';
|
||||
import { GraphQLSchema } from 'graphql';
|
||||
import { IntrospectionResult } from '../../types';
|
||||
export declare type GraphQLConfigEnpointsSubscription = {
|
||||
url: string;
|
||||
connectionParams?: {
|
||||
[name: string]: string | undefined;
|
||||
};
|
||||
};
|
||||
export declare type GraphQLConfigEnpointConfig = {
|
||||
url: string;
|
||||
headers?: {
|
||||
[name: string]: string;
|
||||
};
|
||||
subscription?: GraphQLConfigEnpointsSubscription;
|
||||
};
|
||||
export declare type GraphQLConfigEnpointsMapData = {
|
||||
[env: string]: GraphQLConfigEnpointConfig | string;
|
||||
};
|
||||
export declare type GraphQLConfigEnpointsMap = {
|
||||
[env: string]: GraphQLConfigEnpointConfig | GraphQLEndpoint;
|
||||
};
|
||||
export declare type GraphQLConfigEnpointsData = GraphQLConfigEnpointsMapData;
|
||||
export declare class GraphQLEndpointsExtension {
|
||||
raw: GraphQLConfigEnpointsMapData;
|
||||
private configPath;
|
||||
constructor(endpointConfig: GraphQLConfigEnpointsMapData, configPath: string);
|
||||
getRawEndpointsMap(): GraphQLConfigEnpointsMap;
|
||||
getEnvVarsForEndpoint(endpointName: string): {
|
||||
[name: string]: string | null;
|
||||
};
|
||||
getEndpoint(endpointName: string, env?: {
|
||||
[name: string]: string | undefined;
|
||||
}): GraphQLEndpoint;
|
||||
private getRawEndpoint(endpointName?);
|
||||
}
|
||||
export declare class GraphQLEndpoint {
|
||||
url: string;
|
||||
headers: {
|
||||
[name: string]: string;
|
||||
};
|
||||
subscription: GraphQLConfigEnpointsSubscription;
|
||||
constructor(resolvedConfig: GraphQLConfigEnpointConfig);
|
||||
getClient(clientOptions?: any): GraphQLClient;
|
||||
resolveIntrospection(): Promise<IntrospectionResult>;
|
||||
resolveSchema(): Promise<GraphQLSchema>;
|
||||
resolveSchemaSDL(): Promise<string>;
|
||||
}
|
||||
165
node_modules/graphql-config/lib/extensions/endpoints/EndpointsExtension.js
generated
vendored
Normal file
165
node_modules/graphql-config/lib/extensions/endpoints/EndpointsExtension.js
generated
vendored
Normal file
@ -0,0 +1,165 @@
|
||||
"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) {
|
||||
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 });
|
||||
var graphql_request_1 = require("graphql-request");
|
||||
var graphql_1 = require("graphql");
|
||||
var resolveRefString_1 = require("./resolveRefString");
|
||||
var GraphQLEndpointsExtension = /** @class */ (function () {
|
||||
function GraphQLEndpointsExtension(endpointConfig, configPath) {
|
||||
this.raw = endpointConfig;
|
||||
this.configPath = configPath;
|
||||
}
|
||||
GraphQLEndpointsExtension.prototype.getRawEndpointsMap = function () {
|
||||
var endpoints = {};
|
||||
for (var name_1 in this.raw) {
|
||||
var rawEndpoint = this.raw[name_1];
|
||||
if (typeof rawEndpoint === 'string') {
|
||||
endpoints[name_1] = { url: rawEndpoint };
|
||||
}
|
||||
else {
|
||||
endpoints[name_1] = rawEndpoint;
|
||||
}
|
||||
}
|
||||
return endpoints;
|
||||
};
|
||||
GraphQLEndpointsExtension.prototype.getEnvVarsForEndpoint = function (endpointName) {
|
||||
return resolveRefString_1.getUsedEnvs(this.getRawEndpoint(endpointName));
|
||||
};
|
||||
GraphQLEndpointsExtension.prototype.getEndpoint = function (endpointName, env) {
|
||||
if (env === void 0) { env = process.env; }
|
||||
var endpoint = this.getRawEndpoint(endpointName);
|
||||
try {
|
||||
var resolved = resolveRefString_1.resolveEnvsInValues(endpoint, env);
|
||||
// graphql-config extensions might have already instantiated a GraphQLEndpoint
|
||||
// or derived class from the GraphQLConfigEndpointConfig data. In that case,
|
||||
// getRawEndpoint will already return a GraphQLEndpoint and it should not be overwritten.
|
||||
if (!(resolved instanceof GraphQLEndpoint)) {
|
||||
return new GraphQLEndpoint(resolved);
|
||||
}
|
||||
return resolved;
|
||||
}
|
||||
catch (e) {
|
||||
e.message = this.configPath + ": " + e.message;
|
||||
throw e;
|
||||
}
|
||||
};
|
||||
GraphQLEndpointsExtension.prototype.getRawEndpoint = function (endpointName) {
|
||||
if (endpointName === void 0) { endpointName = process.env.GRAPHQL_CONFIG_ENDPOINT_NAME; }
|
||||
var rawEndpointsMap = this.getRawEndpointsMap();
|
||||
var endpointNames = Object.keys(rawEndpointsMap);
|
||||
if (endpointName == null) {
|
||||
if (endpointNames.length === 1) {
|
||||
endpointName = endpointNames[0];
|
||||
}
|
||||
else {
|
||||
throw new Error('You have to specify endpoint name or define GRAPHQL_CONFIG_ENDPOINT_NAME environment variable');
|
||||
}
|
||||
}
|
||||
var endpoint = rawEndpointsMap[endpointName];
|
||||
if (!endpoint) {
|
||||
throw new Error(this.configPath + ": \"" + endpointName + "\" is not valid endpoint name. " +
|
||||
("Valid endpoint names: " + endpointNames.join(', ')));
|
||||
}
|
||||
if (!endpoint.url && !(endpoint instanceof GraphQLEndpoint)) {
|
||||
throw new Error(this
|
||||
.configPath + ": \"url\" is required but is not specified for \"" + endpointName + "\" endpoint");
|
||||
}
|
||||
return endpoint;
|
||||
};
|
||||
return GraphQLEndpointsExtension;
|
||||
}());
|
||||
exports.GraphQLEndpointsExtension = GraphQLEndpointsExtension;
|
||||
var GraphQLEndpoint = /** @class */ (function () {
|
||||
function GraphQLEndpoint(resolvedConfig) {
|
||||
Object.assign(this, resolvedConfig);
|
||||
}
|
||||
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.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 () {
|
||||
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;
|
||||
2
node_modules/graphql-config/lib/extensions/endpoints/index.d.ts
generated
vendored
Normal file
2
node_modules/graphql-config/lib/extensions/endpoints/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
export * from './EndpointsExtension';
|
||||
export * from './resolveRefString';
|
||||
7
node_modules/graphql-config/lib/extensions/endpoints/index.js
generated
vendored
Normal file
7
node_modules/graphql-config/lib/extensions/endpoints/index.js
generated
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
"use strict";
|
||||
function __export(m) {
|
||||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
||||
}
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
__export(require("./EndpointsExtension"));
|
||||
__export(require("./resolveRefString"));
|
||||
9
node_modules/graphql-config/lib/extensions/endpoints/resolveRefString.d.ts
generated
vendored
Normal file
9
node_modules/graphql-config/lib/extensions/endpoints/resolveRefString.d.ts
generated
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
export declare function resolveRefString(str: string, values?: object): string;
|
||||
export declare function resolveEnvsInValues<T extends {
|
||||
[key: string]: any;
|
||||
}>(config: T, env: {
|
||||
[name: string]: string | undefined;
|
||||
}): T;
|
||||
export declare function getUsedEnvs(config: any): {
|
||||
[name: string]: string;
|
||||
};
|
||||
93
node_modules/graphql-config/lib/extensions/endpoints/resolveRefString.js
generated
vendored
Normal file
93
node_modules/graphql-config/lib/extensions/endpoints/resolveRefString.js
generated
vendored
Normal file
@ -0,0 +1,93 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
function resolveRefString(str, values) {
|
||||
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];
|
||||
res += refValues[i];
|
||||
}
|
||||
res += strings.pop();
|
||||
return res;
|
||||
}
|
||||
exports.resolveRefString = resolveRefString;
|
||||
function resolveEnvsInValues(config, env) {
|
||||
for (var key in config) {
|
||||
var value = config[key];
|
||||
if (typeof value === 'string') {
|
||||
config[key] = resolveRefString(value, { env: env });
|
||||
}
|
||||
else if (typeof value === 'object') {
|
||||
config[key] = resolveEnvsInValues(value, env);
|
||||
}
|
||||
}
|
||||
return config;
|
||||
}
|
||||
exports.resolveEnvsInValues = resolveEnvsInValues;
|
||||
function getUsedEnvs(config) {
|
||||
var result = {};
|
||||
var traverse = function (val) {
|
||||
if (typeof val === 'string') {
|
||||
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);
|
||||
}
|
||||
}
|
||||
else if (typeof val === 'object') {
|
||||
for (var key in val) {
|
||||
traverse(val[key]);
|
||||
}
|
||||
}
|
||||
};
|
||||
traverse(config);
|
||||
return result;
|
||||
}
|
||||
exports.getUsedEnvs = getUsedEnvs;
|
||||
function parseRef(rawRef) {
|
||||
var _a = rawRef.split(/\s*:\s*/), type = _a[0], ref = _a[1];
|
||||
return { type: type, ref: ref };
|
||||
}
|
||||
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);
|
||||
}
|
||||
var refValue = (values.env && values.env[ref]) || process.env[ref];
|
||||
if (!refValue) {
|
||||
if (throwIfUndef) {
|
||||
throw new Error("Environment variable " + ref + " is not set");
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return refValue;
|
||||
}
|
||||
else {
|
||||
// support only 'env' for now
|
||||
throw new Error('Undefined reference type ${refType}. Only "env" is supported');
|
||||
}
|
||||
}
|
||||
function parse(str) {
|
||||
var regex = /\${([^}]*)}/g;
|
||||
var strings = [];
|
||||
var rawRefs = [];
|
||||
var prevIdx = 0;
|
||||
var match;
|
||||
// tslint:disable-next-line:no-conditional-assignment
|
||||
while ((match = regex.exec(str)) !== null) {
|
||||
if (match.index > 0 && str[match.index - 1] === '\\') {
|
||||
continue;
|
||||
}
|
||||
strings.push(str.substring(prevIdx, match.index));
|
||||
rawRefs.push(match[1]);
|
||||
prevIdx = match.index + match[0].length;
|
||||
}
|
||||
strings.push(str.substring(prevIdx));
|
||||
return { strings: strings, rawRefs: rawRefs };
|
||||
}
|
||||
1
node_modules/graphql-config/lib/extensions/index.d.ts
generated
vendored
Normal file
1
node_modules/graphql-config/lib/extensions/index.d.ts
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
export * from './endpoints/';
|
||||
6
node_modules/graphql-config/lib/extensions/index.js
generated
vendored
Normal file
6
node_modules/graphql-config/lib/extensions/index.js
generated
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
"use strict";
|
||||
function __export(m) {
|
||||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
||||
}
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
__export(require("./endpoints/"));
|
||||
4
node_modules/graphql-config/lib/findGraphQLConfigFile.d.ts
generated
vendored
Normal file
4
node_modules/graphql-config/lib/findGraphQLConfigFile.d.ts
generated
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
export declare const GRAPHQL_CONFIG_NAME = ".graphqlconfig";
|
||||
export declare const GRAPHQL_CONFIG_YAML_NAME = ".graphqlconfig.yaml";
|
||||
export declare const GRAPHQL_CONFIG_YML_NAME = ".graphqlconfig.yml";
|
||||
export declare function findGraphQLConfigFile(filePath: string): string;
|
||||
61
node_modules/graphql-config/lib/findGraphQLConfigFile.js
generated
vendored
Normal file
61
node_modules/graphql-config/lib/findGraphQLConfigFile.js
generated
vendored
Normal file
@ -0,0 +1,61 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var path_1 = require("path");
|
||||
var fs_1 = require("fs");
|
||||
var errors_1 = require("./errors");
|
||||
exports.GRAPHQL_CONFIG_NAME = '.graphqlconfig';
|
||||
exports.GRAPHQL_CONFIG_YAML_NAME = '.graphqlconfig.yaml';
|
||||
exports.GRAPHQL_CONFIG_YML_NAME = '.graphqlconfig.yml';
|
||||
function isRootDir(path) {
|
||||
return path_1.dirname(path) === path;
|
||||
}
|
||||
function findGraphQLConfigFile(filePath) {
|
||||
filePath = path_1.resolve(filePath);
|
||||
if (filePath.endsWith(exports.GRAPHQL_CONFIG_NAME) ||
|
||||
filePath.endsWith(exports.GRAPHQL_CONFIG_YAML_NAME) ||
|
||||
filePath.endsWith(exports.GRAPHQL_CONFIG_YML_NAME)) {
|
||||
return filePath;
|
||||
}
|
||||
var currentDir = filePath;
|
||||
while (!isRootDir(currentDir)) {
|
||||
var configPath = path_1.join(currentDir, exports.GRAPHQL_CONFIG_NAME);
|
||||
if (fs_1.existsSync(configPath)) {
|
||||
return configPath;
|
||||
}
|
||||
if (fs_1.existsSync(configPath + '.yaml')) {
|
||||
return configPath + '.yaml';
|
||||
}
|
||||
if (fs_1.existsSync(configPath + '.yml')) {
|
||||
return configPath + '.yml';
|
||||
}
|
||||
currentDir = path_1.dirname(currentDir);
|
||||
}
|
||||
// Try to find GraphQL config in first level of sub-directories.
|
||||
var subDirectories = fs_1.readdirSync(filePath).map(function (dir) { return path_1.join(filePath, dir); }).filter(function (dir) {
|
||||
return (fs_1.lstatSync(dir).isDirectory());
|
||||
});
|
||||
var subDirectoriesWithGraphQLConfig = subDirectories.map(function (subDirectory) {
|
||||
var subDirectoryFiles = fs_1.readdirSync(subDirectory)
|
||||
.filter(function (file) {
|
||||
return !(fs_1.lstatSync(path_1.join(subDirectory, file)).isDirectory());
|
||||
})
|
||||
.map(function (file) {
|
||||
return path_1.basename(path_1.join(subDirectory, file));
|
||||
});
|
||||
if (subDirectoryFiles.includes(exports.GRAPHQL_CONFIG_NAME)) {
|
||||
return subDirectory + "/" + exports.GRAPHQL_CONFIG_NAME;
|
||||
}
|
||||
if (subDirectoryFiles.includes(exports.GRAPHQL_CONFIG_NAME + ".yml")) {
|
||||
return subDirectory + "/" + exports.GRAPHQL_CONFIG_NAME + ".yml";
|
||||
}
|
||||
if (subDirectoryFiles.includes(exports.GRAPHQL_CONFIG_NAME + ".yaml")) {
|
||||
return subDirectory + "/" + exports.GRAPHQL_CONFIG_NAME + ".yaml";
|
||||
}
|
||||
}).filter(function (subDirectory) { return Boolean(subDirectory); });
|
||||
if (subDirectoriesWithGraphQLConfig.length > 0) {
|
||||
return subDirectoriesWithGraphQLConfig[0];
|
||||
}
|
||||
throw new errors_1.ConfigNotFoundError("\"" + exports.GRAPHQL_CONFIG_NAME + "\" file is not available in the provided config " +
|
||||
("directory: " + filePath + "\nPlease check the config directory."));
|
||||
}
|
||||
exports.findGraphQLConfigFile = findGraphQLConfigFile;
|
||||
4
node_modules/graphql-config/lib/getGraphQLConfig.d.ts
generated
vendored
Normal file
4
node_modules/graphql-config/lib/getGraphQLConfig.d.ts
generated
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
import { GraphQLConfig } from './GraphQLConfig';
|
||||
import { GraphQLProjectConfig } from './GraphQLProjectConfig';
|
||||
export declare function getGraphQLConfig(rootDir?: string): GraphQLConfig;
|
||||
export declare function getGraphQLProjectConfig(rootDir?: string, projectName?: string | undefined): GraphQLProjectConfig;
|
||||
18
node_modules/graphql-config/lib/getGraphQLConfig.js
generated
vendored
Normal file
18
node_modules/graphql-config/lib/getGraphQLConfig.js
generated
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
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);
|
||||
return new GraphQLConfig_1.GraphQLConfig(config, configPath);
|
||||
}
|
||||
exports.getGraphQLConfig = getGraphQLConfig;
|
||||
function getGraphQLProjectConfig(rootDir, projectName) {
|
||||
if (projectName === void 0) { projectName = process.env.GRAPHQL_CONFIG_PROJECT; }
|
||||
return getGraphQLConfig(rootDir).getProjectConfig(projectName);
|
||||
}
|
||||
exports.getGraphQLProjectConfig = getGraphQLProjectConfig;
|
||||
8
node_modules/graphql-config/lib/index.d.ts
generated
vendored
Normal file
8
node_modules/graphql-config/lib/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
export { getGraphQLConfig, getGraphQLProjectConfig } from './getGraphQLConfig';
|
||||
export { GRAPHQL_CONFIG_NAME, GRAPHQL_CONFIG_YAML_NAME, findGraphQLConfigFile } from './findGraphQLConfigFile';
|
||||
export { writeSchema, validateConfig, getSchemaExtensions } from './utils';
|
||||
export * from './errors';
|
||||
export * from './extensions/';
|
||||
export { GraphQLConfig } from './GraphQLConfig';
|
||||
export { GraphQLProjectConfig } from './GraphQLProjectConfig';
|
||||
export * from './types';
|
||||
22
node_modules/graphql-config/lib/index.js
generated
vendored
Normal file
22
node_modules/graphql-config/lib/index.js
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
"use strict";
|
||||
function __export(m) {
|
||||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
||||
}
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var getGraphQLConfig_1 = require("./getGraphQLConfig");
|
||||
exports.getGraphQLConfig = getGraphQLConfig_1.getGraphQLConfig;
|
||||
exports.getGraphQLProjectConfig = getGraphQLConfig_1.getGraphQLProjectConfig;
|
||||
var findGraphQLConfigFile_1 = require("./findGraphQLConfigFile");
|
||||
exports.GRAPHQL_CONFIG_NAME = findGraphQLConfigFile_1.GRAPHQL_CONFIG_NAME;
|
||||
exports.GRAPHQL_CONFIG_YAML_NAME = findGraphQLConfigFile_1.GRAPHQL_CONFIG_YAML_NAME;
|
||||
exports.findGraphQLConfigFile = findGraphQLConfigFile_1.findGraphQLConfigFile;
|
||||
var utils_1 = require("./utils");
|
||||
exports.writeSchema = utils_1.writeSchema;
|
||||
exports.validateConfig = utils_1.validateConfig;
|
||||
exports.getSchemaExtensions = utils_1.getSchemaExtensions;
|
||||
__export(require("./errors"));
|
||||
__export(require("./extensions/"));
|
||||
var GraphQLConfig_1 = require("./GraphQLConfig");
|
||||
exports.GraphQLConfig = GraphQLConfig_1.GraphQLConfig;
|
||||
var GraphQLProjectConfig_1 = require("./GraphQLProjectConfig");
|
||||
exports.GraphQLProjectConfig = GraphQLProjectConfig_1.GraphQLProjectConfig;
|
||||
22
node_modules/graphql-config/lib/types.d.ts
generated
vendored
Normal file
22
node_modules/graphql-config/lib/types.d.ts
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
import { IntrospectionQuery } from 'graphql';
|
||||
import { GraphQLConfigEnpointsData } from './extensions/';
|
||||
export declare type IntrospectionResult = {
|
||||
data: IntrospectionQuery;
|
||||
extensions?: Object;
|
||||
errors?: any;
|
||||
};
|
||||
export declare type GraphQLConfigExtensions = {
|
||||
endpoints?: GraphQLConfigEnpointsData;
|
||||
[name: string]: any;
|
||||
};
|
||||
export declare type GraphQLResolvedConfigData = {
|
||||
schemaPath: string;
|
||||
includes?: Array<string>;
|
||||
excludes?: Array<string>;
|
||||
extensions?: GraphQLConfigExtensions;
|
||||
};
|
||||
export declare type GraphQLConfigData = GraphQLResolvedConfigData & {
|
||||
projects?: {
|
||||
[projectName: string]: GraphQLResolvedConfigData;
|
||||
};
|
||||
};
|
||||
2
node_modules/graphql-config/lib/types.js
generated
vendored
Normal file
2
node_modules/graphql-config/lib/types.js
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
20
node_modules/graphql-config/lib/utils.d.ts
generated
vendored
Normal file
20
node_modules/graphql-config/lib/utils.d.ts
generated
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
import { GraphQLSchema, IntrospectionQuery } from 'graphql';
|
||||
import { GraphQLConfigData, IntrospectionResult } from './types';
|
||||
export declare function readConfig(configPath: string): GraphQLConfigData;
|
||||
export declare function writeConfig(configPath: string, config: GraphQLConfigData): void;
|
||||
export declare function normalizeGlob(glob: string): string;
|
||||
export declare function matchesGlobs(filePath: string, configDir: string, globs?: string[]): boolean;
|
||||
export declare function validateConfig(config: GraphQLConfigData): void;
|
||||
export declare function mergeConfigs(dest: GraphQLConfigData, src: GraphQLConfigData): GraphQLConfigData;
|
||||
export declare function schemaToIntrospection(schema: GraphQLSchema): Promise<IntrospectionResult>;
|
||||
export declare function introspectionToSchema(introspection: IntrospectionResult | (IntrospectionQuery & {
|
||||
errors: undefined;
|
||||
data: undefined;
|
||||
})): GraphQLSchema;
|
||||
export declare function readSchema(path: any): GraphQLSchema;
|
||||
export declare function writeSchema(path: string, schema: GraphQLSchema, schemaExtensions?: {
|
||||
[name: string]: string;
|
||||
}): Promise<void>;
|
||||
export declare function getSchemaExtensions(path: string): {
|
||||
[name: string]: string;
|
||||
};
|
||||
227
node_modules/graphql-config/lib/utils.js
generated
vendored
Normal file
227
node_modules/graphql-config/lib/utils.js
generated
vendored
Normal file
@ -0,0 +1,227 @@
|
||||
"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) {
|
||||
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 });
|
||||
var fs_1 = require("fs");
|
||||
var path_1 = require("path");
|
||||
var graphql_import_1 = require("graphql-import");
|
||||
var minimatch = require("minimatch");
|
||||
var yaml = require("js-yaml");
|
||||
var graphql_1 = require("graphql");
|
||||
function readConfig(configPath) {
|
||||
var config;
|
||||
try {
|
||||
var rawConfig = fs_1.readFileSync(configPath, 'utf-8');
|
||||
if (configPath.endsWith('.yaml') || configPath.endsWith('.yml')) {
|
||||
config = yaml.safeLoad(rawConfig);
|
||||
}
|
||||
else {
|
||||
config = JSON.parse(rawConfig);
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
error.message = "Parsing " + configPath + " file has failed.\n" + error.message;
|
||||
throw error;
|
||||
}
|
||||
return config;
|
||||
}
|
||||
exports.readConfig = readConfig;
|
||||
function writeConfig(configPath, config) {
|
||||
var configContents;
|
||||
if (configPath.endsWith('.yaml') || configPath.endsWith('.yml')) {
|
||||
configContents = yaml.safeDump(config);
|
||||
}
|
||||
else {
|
||||
configContents = JSON.stringify(config);
|
||||
}
|
||||
fs_1.writeFileSync(configPath, configContents, 'utf-8');
|
||||
}
|
||||
exports.writeConfig = writeConfig;
|
||||
function normalizeGlob(glob) {
|
||||
if (glob.startsWith('./')) {
|
||||
return glob.substr(2);
|
||||
}
|
||||
return glob;
|
||||
}
|
||||
exports.normalizeGlob = normalizeGlob;
|
||||
function matchesGlobs(filePath, configDir, globs) {
|
||||
return (globs || []).some(function (glob) {
|
||||
try {
|
||||
var globStat = fs_1.lstatSync(path_1.join(configDir, glob));
|
||||
var newGlob = glob.length === 0 ? '.' : glob;
|
||||
var globToMatch = globStat.isDirectory() ? glob + "/**" : glob;
|
||||
return minimatch(filePath, globToMatch, { matchBase: true });
|
||||
}
|
||||
catch (error) {
|
||||
// Out of errors that lstat provides, EACCES and ENOENT are the
|
||||
// most likely. For both cases, run the match with the raw glob
|
||||
// and return the result.
|
||||
return minimatch(filePath, glob, { matchBase: true });
|
||||
}
|
||||
});
|
||||
}
|
||||
exports.matchesGlobs = matchesGlobs;
|
||||
function validateConfig(config) {
|
||||
// FIXME: implement
|
||||
}
|
||||
exports.validateConfig = validateConfig;
|
||||
function mergeConfigs(dest, src) {
|
||||
var result = __assign({}, dest, src);
|
||||
if (dest.extensions && src.extensions) {
|
||||
result.extensions = __assign({}, dest.extensions, src.extensions);
|
||||
}
|
||||
if (dest.projects && src.projects) {
|
||||
result.projects = __assign({}, dest.projects, src.projects);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
exports.mergeConfigs = mergeConfigs;
|
||||
function schemaToIntrospection(schema) {
|
||||
return graphql_1.graphql(schema, graphql_1.introspectionQuery);
|
||||
}
|
||||
exports.schemaToIntrospection = schemaToIntrospection;
|
||||
// Predicate for errors/data can be removed after typescript 2.7.
|
||||
// See: https://github.com/Microsoft/TypeScript/pull/19513
|
||||
function introspectionToSchema(introspection) {
|
||||
if (introspection.errors != null) {
|
||||
throw new Error('Introspection result contains errors');
|
||||
}
|
||||
return graphql_1.buildClientSchema(introspection.data ? introspection.data : introspection);
|
||||
}
|
||||
exports.introspectionToSchema = introspectionToSchema;
|
||||
function readSchema(path) {
|
||||
// FIXME: prefix error
|
||||
switch (path_1.extname(path)) {
|
||||
case '.graphql':
|
||||
return valueToSchema(graphql_import_1.importSchema(path));
|
||||
case '.json':
|
||||
var data = fs_1.readFileSync(path, { encoding: 'utf-8' });
|
||||
var introspection = JSON.parse(data);
|
||||
return valueToSchema(introspection);
|
||||
default:
|
||||
throw new Error('Unsupported schema file extention. Only ".graphql" and ".json" are supported');
|
||||
}
|
||||
}
|
||||
exports.readSchema = readSchema;
|
||||
function valueToSchema(schema) {
|
||||
if (schema instanceof graphql_1.GraphQLSchema) {
|
||||
return schema;
|
||||
}
|
||||
else if (typeof schema === 'string') {
|
||||
return graphql_1.buildSchema(schema);
|
||||
}
|
||||
else if (schema instanceof graphql_1.Source) {
|
||||
return graphql_1.buildSchema(schema);
|
||||
}
|
||||
else if (typeof schema === 'object' && !Array.isArray(schema)) {
|
||||
return introspectionToSchema(schema);
|
||||
}
|
||||
throw new Error('Can not convert data to a schema');
|
||||
}
|
||||
function writeSchema(path, schema, schemaExtensions) {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var data, _a, name_1, introspection, _b;
|
||||
return __generator(this, function (_c) {
|
||||
switch (_c.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 = '';
|
||||
if (schemaExtensions) {
|
||||
for (name_1 in schemaExtensions) {
|
||||
data += "# " + name_1 + ": " + schemaExtensions[name_1] + "\n";
|
||||
}
|
||||
data += '\n';
|
||||
}
|
||||
data += graphql_1.printSchema(schema);
|
||||
return [3 /*break*/, 5];
|
||||
case 2: return [4 /*yield*/, schemaToIntrospection(schema)];
|
||||
case 3:
|
||||
introspection = _c.sent();
|
||||
introspection.extensions = (_b = {},
|
||||
_b['graphql-config'] = schemaExtensions,
|
||||
_b);
|
||||
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;
|
||||
function getSchemaExtensions(path) {
|
||||
var data = fs_1.readFileSync(path, 'utf-8');
|
||||
switch (path_1.extname(path)) {
|
||||
case '.graphql':
|
||||
var extensions = {};
|
||||
for (var _i = 0, _a = data.split('\n'); _i < _a.length; _i++) {
|
||||
var line = _a[_i];
|
||||
var result = /# ([^:]+): (.+)$/.exec(line);
|
||||
if (result == null) {
|
||||
break;
|
||||
}
|
||||
var _ = result[0], key = result[1], value = result[2];
|
||||
extensions[key] = value;
|
||||
}
|
||||
return extensions;
|
||||
case '.json':
|
||||
var introspection = JSON.parse(data);
|
||||
if (!introspection.extentions) {
|
||||
return {};
|
||||
}
|
||||
return introspection.extensions['graphql-config'] || {};
|
||||
default:
|
||||
throw new Error('Unsupported schema file extention. Only ".graphql" and ".json" are supported');
|
||||
}
|
||||
}
|
||||
exports.getSchemaExtensions = getSchemaExtensions;
|
||||
89
node_modules/graphql-config/package.json
generated
vendored
Normal file
89
node_modules/graphql-config/package.json
generated
vendored
Normal file
@ -0,0 +1,89 @@
|
||||
{
|
||||
"_from": "graphql-config@^2.0.1",
|
||||
"_id": "graphql-config@2.2.1",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-U8+1IAhw9m6WkZRRcyj8ZarK96R6lQBQ0an4lp76Ps9FyhOXENC5YQOxOFGm5CxPrX2rD0g3Je4zG5xdNJjwzQ==",
|
||||
"_location": "/graphql-config",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "graphql-config@^2.0.1",
|
||||
"name": "graphql-config",
|
||||
"escapedName": "graphql-config",
|
||||
"rawSpec": "^2.0.1",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^2.0.1"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/eslint-plugin-graphql"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/graphql-config/-/graphql-config-2.2.1.tgz",
|
||||
"_shasum": "5fd0ec77ac7428ca5fb2026cf131be10151a0cb2",
|
||||
"_spec": "graphql-config@^2.0.1",
|
||||
"_where": "/Users/stefanfejes/Projects/30-seconds-of-python-code/node_modules/eslint-plugin-graphql",
|
||||
"author": {
|
||||
"name": "Johannes Schickling",
|
||||
"email": "johannes@graph.cool"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/graphcool/graphql-config/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"graphql-import": "^0.7.1",
|
||||
"graphql-request": "^1.5.0",
|
||||
"js-yaml": "^3.10.0",
|
||||
"lodash": "^4.17.4",
|
||||
"minimatch": "^3.0.4"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "The easiest way to configure your development environment with your GraphQL schema (supported by most tools, editors & IDEs)",
|
||||
"devDependencies": {
|
||||
"@types/graphql": "0.13.3",
|
||||
"@types/node": "9.4.6",
|
||||
"@types/node-fetch": "1.6.7",
|
||||
"ava": "0.25.0",
|
||||
"cpx": "1.5.0",
|
||||
"graphql": "14.0.2",
|
||||
"rimraf": "2.6.2",
|
||||
"tslint": "5.9.1",
|
||||
"tslint-config-standard": "7.0.0",
|
||||
"typescript": "2.7.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 6.0.0"
|
||||
},
|
||||
"files": [
|
||||
"LICENSE",
|
||||
"README.md",
|
||||
"lib/"
|
||||
],
|
||||
"homepage": "https://github.com/graphcool/graphql-config#readme",
|
||||
"keywords": [
|
||||
"graphql",
|
||||
"config",
|
||||
"relay",
|
||||
"apollo"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "lib/index.js",
|
||||
"name": "graphql-config",
|
||||
"peerDependencies": {
|
||||
"graphql": "^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/graphcool/graphql-config.git"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "npm run clean && tsc",
|
||||
"clean": "rimraf lib",
|
||||
"copy-test-assets": "cpx \"src/**/{.graphqlconfig*,*.graphql,*.json}\" lib",
|
||||
"prepublish": "npm run build",
|
||||
"test": "tslint src/**/*.ts && npm run test-only",
|
||||
"test-only": "npm run build && npm run copy-test-assets && ava --verbose lib/__tests__/**/*.js --serial"
|
||||
},
|
||||
"types": "lib/index.d.ts",
|
||||
"version": "2.2.1"
|
||||
}
|
||||
Reference in New Issue
Block a user