easygraphql-parser
Advanced tools
Comparing version
'use strict' | ||
const { parse, Kind, printSchema, buildClientSchema, GraphQLSchema, buildASTSchema } = require('graphql') | ||
const mergeWith = require('lodash.mergewith') | ||
const { mergeTypes } = require('merge-graphql-schemas') | ||
@@ -37,2 +37,3 @@ function getOperationTypes (schema, nodeMap) { | ||
const d = doc.definitions[i] | ||
const typeName = d && d.name ? d.name.value : undefined | ||
switch (d.kind) { | ||
@@ -51,5 +52,2 @@ case Kind.SCHEMA_DEFINITION: | ||
case Kind.INPUT_OBJECT_TYPE_DEFINITION: | ||
case Kind.OBJECT_TYPE_EXTENSION: | ||
// Get the name of the type on the schema | ||
const typeName = d.name.value | ||
// Check if it is already define, it can only be one time | ||
@@ -61,2 +59,9 @@ if (nodeMap[typeName]) { | ||
break | ||
case Kind.OBJECT_TYPE_EXTENSION: | ||
if (nodeMap[typeName]) { | ||
nodeMap[typeName].fields = [].concat(nodeMap[typeName].fields, d.fields) | ||
break | ||
} | ||
nodeMap[typeName] = d | ||
break | ||
case Kind.DIRECTIVE_DEFINITION: | ||
@@ -203,17 +208,5 @@ directiveDefs.push(d) | ||
function mergeNestedFields (objValue, srcValue) { | ||
if (Array.isArray(objValue)) { | ||
return objValue.concat(srcValue) | ||
} | ||
} | ||
function schemaParser (source) { | ||
if (Array.isArray(source)) { | ||
let result = {} | ||
source.forEach(sourceVal => { | ||
const schema = schemaBuilder(parse(sourceVal, { allowLegacySDLImplementsInterfaces: true })) | ||
mergeWith(result, schema, mergeNestedFields) | ||
}) | ||
return result | ||
source = mergeTypes(source, { all: true }) | ||
} | ||
@@ -220,0 +213,0 @@ |
{ | ||
"name": "easygraphql-parser", | ||
"version": "0.0.11", | ||
"version": "0.0.12", | ||
"description": "Parse GraphQL Schema", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "nyc --check-coverage --lines 95 mocha", | ||
"test": "nyc --check-coverage --lines 94 mocha", | ||
"standard": "standard", | ||
@@ -38,4 +38,4 @@ "standard-fix": "standard --fix", | ||
"dependencies": { | ||
"graphql": "^14.0.2", | ||
"lodash.mergewith": "^4.6.1" | ||
"graphql": "^14.4.0", | ||
"merge-graphql-schemas": "^1.5.8" | ||
}, | ||
@@ -48,3 +48,3 @@ "peerDependencies": { | ||
"coveralls": "^3.0.2", | ||
"husky": "^2.2.0", | ||
"husky": "^3.0.0", | ||
"mocha": "^6.1.4", | ||
@@ -51,0 +51,0 @@ "nyc": "^14.0.0", |
110976
-0.12%1735
-0.29%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
Updated