graphql-config-extension-graphcool
Advanced tools
Comparing version 0.2.0 to 0.3.0
@@ -54,3 +54,3 @@ "use strict"; | ||
}; | ||
return [4 /*yield*/, index_1.patchEndpointsToConfig(config, process.cwd())]; | ||
return [4 /*yield*/, index_1.patchEndpointsToConfigData(config, process.cwd())]; | ||
case 1: | ||
@@ -57,0 +57,0 @@ newConfig = _a.sent(); |
@@ -1,2 +0,7 @@ | ||
import { GraphQLConfigData } from 'graphql-config'; | ||
export declare function patchEndpointsToConfig(config: GraphQLConfigData, cwd?: string, envVars?: any): Promise<GraphQLConfigData>; | ||
import { GraphQLConfig, GraphQLConfigData, GraphQLProjectConfig } from 'graphql-config'; | ||
export declare function patchEndpointsToConfig<T extends GraphQLConfig | GraphQLProjectConfig>(config: T, cwd?: string, envVars?: { | ||
[key: string]: any; | ||
}): Promise<T>; | ||
export declare function patchEndpointsToConfigData(config: GraphQLConfigData, cwd?: string, envVars?: { | ||
[key: string]: any; | ||
}): Promise<GraphQLConfigData>; |
@@ -52,23 +52,46 @@ "use strict"; | ||
return __awaiter(this, void 0, void 0, function () { | ||
var _this = this; | ||
var newConfig, home, globalGraphcoolPath, globalConfigPath, globalClusterCachePath, env, cache, _a; | ||
var _a; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
_a = config; | ||
return [4 /*yield*/, patchEndpointsToConfigData(config.config, cwd, envVars)]; | ||
case 1: | ||
_a.config = _b.sent(); | ||
return [2 /*return*/, config]; | ||
} | ||
}); | ||
}); | ||
} | ||
exports.patchEndpointsToConfig = patchEndpointsToConfig; | ||
function patchEndpointsToConfigData(config, cwd, envVars) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var _this = this; | ||
var allExtensions, newConfig, home, globalClusterCachePath, cache, globalConfigPath, env, _a, _b; | ||
return __generator(this, function (_c) { | ||
switch (_c.label) { | ||
case 0: | ||
allExtensions = [ | ||
config.extensions | ||
].concat(lodash_1.values(config.projects).map(function (p) { return p.extensions; })); | ||
if (!allExtensions.some(function (e) { return e && e.graphcool; })) { | ||
return [2 /*return*/, config]; | ||
} | ||
newConfig = __assign({}, config); | ||
home = os.homedir(); | ||
globalGraphcoolPath = path.join(home, '.graphcool/'); | ||
globalClusterCachePath = path.join(home, '.graphcool/cache.yml'); | ||
cache = new graphcool_yml_1.ClusterCache(globalClusterCachePath); | ||
globalConfigPath = path.join(home, '.graphcool/config.yml'); | ||
globalClusterCachePath = path.join(home, '.graphcool/cache.yml'); | ||
env = new graphcool_yml_1.Environment(globalConfigPath); | ||
cache = new graphcool_yml_1.ClusterCache(globalClusterCachePath); | ||
return [4 /*yield*/, env.load({})]; | ||
case 1: | ||
_b.sent(); | ||
_c.sent(); | ||
if (!(newConfig.extensions && newConfig.extensions.graphcool)) return [3 /*break*/, 3]; | ||
_a = lodash_1.merge; | ||
_a = lodash_1.set; | ||
_b = [newConfig, | ||
['extensions', 'endpoints']]; | ||
return [4 /*yield*/, getEndpointsFromPath(env, newConfig.extensions.graphcool, cache, cwd, envVars)]; | ||
case 2: | ||
newConfig = _a.apply(void 0, [_b.sent()]); | ||
_b.label = 3; | ||
_a.apply(void 0, _b.concat([_c.sent()])); | ||
_c.label = 3; | ||
case 3: | ||
@@ -95,4 +118,4 @@ if (!newConfig.projects) return [3 /*break*/, 5]; | ||
case 4: | ||
_b.sent(); | ||
_b.label = 5; | ||
_c.sent(); | ||
_c.label = 5; | ||
case 5: return [2 /*return*/, newConfig]; | ||
@@ -103,3 +126,3 @@ } | ||
} | ||
exports.patchEndpointsToConfig = patchEndpointsToConfig; | ||
exports.patchEndpointsToConfigData = patchEndpointsToConfigData; | ||
function getEndpointsFromPath(env, ymlPath, cache, cwd, envVars) { | ||
@@ -106,0 +129,0 @@ return __awaiter(this, void 0, void 0, function () { |
{ | ||
"name": "graphql-config-extension-graphcool", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"main": "dist/index.js", | ||
@@ -15,9 +15,15 @@ "types": "dist/index.d.ts", | ||
"devDependencies": { | ||
"@types/node": "^8.5.2" | ||
"@types/node": "^8.5.2", | ||
"ts-node": "^4.1.0", | ||
"typescript": "^2.6.2" | ||
}, | ||
"scripts": { | ||
"test": "jest", | ||
"test": "cd src/example && ts-node test.ts", | ||
"prepare": "npm run build", | ||
"build": "tsc -d" | ||
"build": "rm -rf dist && tsc -d" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/graphcool/graphql-config-extension-graphcool.git" | ||
} | ||
} |
# graphql-config-extension-graphcool | ||
[![npm version](https://badge.fury.io/js/graphql-config-extension-graphcool.svg)](https://badge.fury.io/js/graphql-config-extension-graphcool) [![Build Status](https://travis-ci.org/graphcool/graphql-config-extension-graphcool.svg?branch=master)](https://travis-ci.org/graphcool/graphql-config-extension-graphcool) | ||
Injects endpoints and headers into a GraphQL Config instance based on a given graphcool.yml | ||
@@ -3,0 +6,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
18219
232
27
0
3