graphql-config
Advanced tools
Comparing version 1.0.9 to 1.1.0
@@ -5,2 +5,3 @@ "use strict"; | ||
var path_1 = require("path"); | ||
var graphql_1 = require("graphql"); | ||
var schema = require('../schema.json'); | ||
@@ -17,3 +18,5 @@ var _1 = require("../../"); | ||
}); | ||
ava_1.default('returns a correct root dir', function (t) { return t.deepEqual(config.configDir, CONFIG_DIR); }); | ||
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) { | ||
@@ -23,1 +26,9 @@ t.deepEqual(config.getProjectConfig('testWithSchema').schemaPath, path_1.join(CONFIG_DIR, '__schema__/StarWarsSchema.graphql')); | ||
}); | ||
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); | ||
}); |
@@ -48,2 +48,3 @@ "use strict"; | ||
var path_1 = require("path"); | ||
var graphql_import_1 = require("graphql-import"); | ||
var minimatch = require("minimatch"); | ||
@@ -135,8 +136,8 @@ var yaml = require("js-yaml"); | ||
function readSchema(path) { | ||
var data = fs_1.readFileSync(path, 'utf-8'); | ||
// FIXME: prefix error | ||
switch (path_1.extname(path)) { | ||
case '.graphql': | ||
return valueToSchema(data); | ||
return valueToSchema(graphql_import_1.importSchema(path)); | ||
case '.json': | ||
var data = fs_1.readFileSync(path, { encoding: 'utf-8' }); | ||
var introspection = JSON.parse(data); | ||
@@ -153,5 +154,8 @@ return valueToSchema(introspection); | ||
} | ||
else if (typeof schema === 'string' || schema instanceof graphql_1.Source) { | ||
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)) { | ||
@@ -213,3 +217,3 @@ return introspectionToSchema(schema); | ||
} | ||
var _ = result[0], key = result[1], value = result[2]; | ||
var _1 = result[0], key = result[1], value = result[2]; | ||
extensions[key] = value; | ||
@@ -216,0 +220,0 @@ } |
{ | ||
"name": "graphql-config", | ||
"version": "1.0.9", | ||
"version": "1.1.0", | ||
"description": "The easiest way to configure your development environment with your GraphQL schema (supported by most tools, editors & IDEs)", | ||
@@ -16,3 +16,3 @@ "main": "lib/index.js", | ||
"build": "npm run clean && tsc", | ||
"copy-test-assets": "cpx \"src/**/{.graphqlconfig,.graphqlconfig.yml,.graphqlconfig.yaml,*.json}\" lib", | ||
"copy-test-assets": "cpx \"src/**/{.graphqlconfig*,*.graphql,*.json}\" lib", | ||
"test-only": "npm run build && npm run copy-test-assets && ava --verbose lib/__tests__/**/*.js --serial", | ||
@@ -54,3 +54,3 @@ "test": "tslint src/**/*.ts && npm run test-only" | ||
"@types/node-fetch": "1.6.7", | ||
"ava": "^0.23.0", | ||
"ava": "^0.24.0", | ||
"babel-polyfill": "^6.26.0", | ||
@@ -66,2 +66,3 @@ "babel-preset-es2015": "^6.16.0", | ||
"graphql": "^0.11.7", | ||
"graphql-import": "^0.1.5", | ||
"graphql-request": "^1.4.0", | ||
@@ -68,0 +69,0 @@ "js-yaml": "^3.10.0", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
78628
1438
6
+ Addedgraphql-import@^0.1.5
+ Added@types/graphql@0.11.7(transitive)
+ Added@types/lodash@4.17.13(transitive)
+ Addedgraphql@0.12.3(transitive)
+ Addedgraphql-import@0.1.9(transitive)
+ Addedlodash@4.17.21(transitive)