Socket
Socket
Sign inDemoInstall

graphql-config

Package Overview
Dependencies
Maintainers
3
Versions
319
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphql-config - npm Package Compare versions

Comparing version 1.0.0-rc.5 to 1.0.0-rc.6

lib/extensions/endpoints/EndpointsExtension.d.ts

59

lib/__tests__/endpoint-extension/resolve.js

@@ -54,3 +54,3 @@ "use strict";

ava_1.default('getEndpointsMap when endpoint is string url', function (t) { return __awaiter(_this, void 0, void 0, function () {
var configData, config, endpoint;
var configData, config, endpoints;
return __generator(this, function (_a) {

@@ -60,8 +60,10 @@ configData = {

extensions: {
endpoint: 'http://default',
endpoints: {
dev: 'http://default',
},
},
};
config = new _1.GraphQLProjectConfig(configData, confPath);
endpoint = config.endpointExtension;
t.deepEqual(endpoint && endpoint.getRawEndpointsMap(), { default: { url: 'http://default' } });
endpoints = config.endpointsExtension;
t.deepEqual(endpoints && endpoints.getRawEndpointsMap(), { dev: { url: 'http://default' } });
return [2 /*return*/];

@@ -76,6 +78,8 @@ });

extensions: {
endpoint: {
url: 'http://default',
subscription: {
url: 'ws://test',
endpoints: {
dev: {
url: 'http://default',
subscription: {
url: 'ws://test',
},
},

@@ -86,4 +90,4 @@ },

config = new _1.GraphQLProjectConfig(configData, confPath, undefined);
endpoint = config.endpointExtension;
t.deepEqual(endpoint && endpoint.getRawEndpointsMap(), { default: configData.extensions.endpoint });
endpoint = config.endpointsExtension;
t.deepEqual(endpoint && endpoint.getRawEndpointsMap(), { dev: configData.extensions.endpoints.dev });
return [2 /*return*/];

@@ -98,9 +102,4 @@ });

extensions: {
endpoint: {
dev: {
url: 'http://dev',
subscription: {
url: 'ws://dev',
},
},
endpoints: {
dev: 'http://dev',
prod: {

@@ -116,4 +115,14 @@ url: 'http://prod',

config = new _1.GraphQLProjectConfig(configData, confPath, undefined);
endpoint = config.endpointExtension;
t.deepEqual(endpoint && endpoint.getRawEndpointsMap(), configData.extensions.endpoint);
endpoint = config.endpointsExtension;
t.deepEqual(endpoint && endpoint.getRawEndpointsMap(), {
dev: {
url: 'http://dev',
},
prod: {
url: 'http://prod',
subscription: {
url: 'ws://prod',
},
}
});
return [2 /*return*/];

@@ -128,3 +137,3 @@ });

extensions: {
endpoint: {
endpoints: {
dev: {

@@ -140,3 +149,3 @@ url: 'http://dev',

config = new _1.GraphQLProjectConfig(configData, confPath, undefined);
endpoint = config.endpointExtension;
endpoint = config.endpointsExtension;
error = t.throws(function () { return endpoint && endpoint.getEndpoint('prod').resolveSchema(); });

@@ -157,10 +166,12 @@ t.regex(error.message, /^Endpoint.*is not defined/);

extensions: {
endpoint: 'http://127.0.0.1:33333',
endpoints: {
dev: 'http://127.0.0.1:33333'
}
},
};
config = new _1.GraphQLProjectConfig(configData, confPath, undefined);
if (!config.endpointExtension) {
if (!config.endpointsExtension) {
throw 'endpointExtension can\'t be empty';
}
return [4 /*yield*/, config.endpointExtension.getEndpoint().resolveSchema()];
return [4 /*yield*/, config.endpointsExtension.getEndpoint('dev').resolveSchema()];
case 1:

@@ -167,0 +178,0 @@ schema = _a.sent();

@@ -42,9 +42,9 @@ "use strict";

var utils_1 = require("../utils");
var endpoint;
var endpoints;
ava_1.default.beforeEach(function () {
endpoint = _1.getGraphQLProjectConfig().endpointExtension;
endpoints = _1.getGraphQLProjectConfig().endpointsExtension;
});
ava_1.default('getEndpointsMap', function (t) { return __awaiter(_this, void 0, void 0, function () {
return __generator(this, function (_a) {
t.deepEqual(endpoint.getRawEndpointsMap(), {
t.deepEqual(endpoints.getRawEndpointsMap(), {
default: {

@@ -59,3 +59,3 @@ url: '${env:TEST_ENDPOINT_URL}',

return __generator(this, function (_a) {
t.deepEqual(endpoint.getEnvVarsForEndpoint('default'), { TEST_ENDPOINT_URL: null });
t.deepEqual(endpoints.getEnvVarsForEndpoint('default'), { TEST_ENDPOINT_URL: null });
return [2 /*return*/];

@@ -69,3 +69,3 @@ });

process.env['TEST_ENDPOINT_URL'] = testURL;
t.deepEqual(endpoint.getEnvVarsForEndpoint('default'), { TEST_ENDPOINT_URL: testURL });
t.deepEqual(endpoints.getEnvVarsForEndpoint('default'), { TEST_ENDPOINT_URL: testURL });
delete process.env['TEST_ENDPOINT_URL'];

@@ -77,3 +77,3 @@ return [2 /*return*/];

return __generator(this, function (_a) {
t.throws(function () { return endpoint.getEndpoint('default').resolveSchema(); });
t.throws(function () { return endpoints.getEndpoint('default').resolveSchema(); });
return [2 /*return*/];

@@ -89,3 +89,3 @@ });

t.notThrows(function () {
return endpoint.getEndpoint('default', { TEST_ENDPOINT_URL: 'http://127.0.0.1:33333' }).resolveSchema();
return endpoints.getEndpoint('default', { TEST_ENDPOINT_URL: 'http://127.0.0.1:33333' }).resolveSchema();
});

@@ -92,0 +92,0 @@ return [2 /*return*/];

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

export * from './endpoint/';
export * from './endpoints/';

@@ -6,2 +6,2 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
__export(require("./endpoint/"));
__export(require("./endpoints/"));
import { GraphQLSchema } from 'graphql';
import { IntrospectionResult, GraphQLResolvedConfigData, GraphQLConfigData, GraphQLConfigExtensions } from './types';
import { GraphQLEndpointExtension } from './extensions';
import { GraphQLEndpointsExtension } from './extensions';
export declare class GraphQLProjectConfig {

@@ -19,3 +19,3 @@ config: GraphQLResolvedConfigData;

readonly extensions: GraphQLConfigExtensions;
readonly endpointExtension: GraphQLEndpointExtension | null;
readonly endpointsExtension: GraphQLEndpointsExtension | null;
}

@@ -124,3 +124,3 @@ "use strict";

});
Object.defineProperty(GraphQLProjectConfig.prototype, "endpointExtension", {
Object.defineProperty(GraphQLProjectConfig.prototype, "endpointsExtension", {
/*

@@ -130,4 +130,4 @@ extension related helper functions

get: function () {
return this.extensions.endpoint ?
new extensions_1.GraphQLEndpointExtension(this.extensions.endpoint, this.configPath) : null;
return this.extensions.endpoints ?
new extensions_1.GraphQLEndpointsExtension(this.extensions.endpoints, this.configPath) : null;
},

@@ -134,0 +134,0 @@ enumerable: true,

{
"name": "graphql-config",
"version": "1.0.0-rc.5",
"version": "1.0.0-rc.6",
"description": "The easiest way to configure your development environment with your GraphQL schema (supported by most tools, editors & IDEs)",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -10,4 +10,6 @@ # graphql-config

### 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_)

@@ -25,2 +27,4 @@ * [atom-language-graphql](https://github.com/rmosolgo/language-graphql) - GraphQL support for Atom text editor (_pending_)

**[Go to `graphql-config` library docs](#graphql-config-api)**
## Usage

@@ -31,4 +35,2 @@

> Note: This requires Node 5 installed or higher
### Simplest use case

@@ -45,5 +47,13 @@

or
```json
{
"schemaPath": "schema.json"
}
```
### Specifying includes/excludes files
You can specify which files to includes/excludes using the corresponding options:
You can specify which files are included/excluded using the corresponding options:

@@ -64,3 +74,4 @@ ```json

You may specify your endpoints info in `.graphqlconfig`. The simplest case:
You may specify your endpoints info in `.graphqlconfig` which may be used by some tools.
The simplest case:

@@ -71,3 +82,5 @@ ```json

"extensions": {
"endpoint": "https://example.com/graphql"
"endpoints": {
"dev": "https://example.com/graphql"
}
}

@@ -77,4 +90,4 @@ }

In case you need provide addition information for example headers to authenticate your GraphQL endpoint or
a endpoint for subscription you can use expanded version:
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:

@@ -85,11 +98,13 @@ ```json

"extensions": {
"endpoint": {
"url": "https://example.com/graphql",
"headers": {
"Authorization": "Bearer ${env:AUTH_TOKEN_ENV}"
},
"subscription": {
"url": "ws://example.com/graphql",
"connectionParams": {
"Token": "${env:YOUR_APP_TOKEN}"
"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}"
}
}

@@ -110,3 +125,3 @@ }

"extensions": {
"endpoint": {
"endpoints": {
"prod": {

@@ -129,3 +144,3 @@ "url": "https://your-app.com/graphql",

### Multi-project configuration
### Multi-project configuration (advanced)
> TBD

@@ -139,13 +154,16 @@

Additional to the format specification, it provides the `graphql-config` 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.
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 [![Build Status](https://travis-ci.org/graphcool/graphql-config.svg?branch=master)](https://travis-ci.org/graphcool/graphql-config) [![npm version](https://badge.fury.io/js/graphql-config.svg)](https://badge.fury.io/js/graphql-config)
## `graphql-config` API
[![Build Status](https://travis-ci.org/graphcool/graphql-config.svg?branch=master)](https://travis-ci.org/graphcool/graphql-config) [![npm version](https://badge.fury.io/js/graphql-config.svg)](https://badge.fury.io/js/graphql-config)
> **WIP: More examples are coming soon**
Here are very basic examples of how to use `graphql-config` library.
You can find **[the detailed documentation here](docs/)**
### getGraphQLProjectConfig
> NOTE: if you work with files (e.g. editor plugin, linter, etc) use GraphQLConfig
class and `getConfigForFile` method to get instance of the correct `GraphQLProjectConfig`
**NOTE:** if your tool works on per-file basis (e.g. editor plugin, linter, etc) use
[`getGraphQLConfig`](#getGraphQLConfig) function

@@ -152,0 +170,0 @@ `getGraphQLProjectConfig` should be used by tools that do not work on per-file basis

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc