@graphql-tools/merge
Advanced tools
Comparing version 6.0.0-alpha.1 to 6.0.0-alpha-08f96bd.0
@@ -814,2 +814,5 @@ 'use strict'; | ||
function applyExtensionObject(obj, extensions) { | ||
if (!obj) { | ||
return; | ||
} | ||
obj.extensions = [obj.extensions || {}, extensions || {}].reduce(utils.mergeDeep, {}); | ||
@@ -821,22 +824,26 @@ } | ||
const type = schema.getType(typeName); | ||
applyExtensionObject(type, data.extensions); | ||
if (data.type === 'object' || data.type === 'interface') { | ||
for (const [fieldName, fieldData] of Object.entries(data.fields)) { | ||
const field = type.getFields()[fieldName]; | ||
applyExtensionObject(field, fieldData.extensions); | ||
for (const [arg, argData] of Object.entries(fieldData.arguments)) { | ||
applyExtensionObject(field.args.find(a => a.name === arg), argData); | ||
if (type) { | ||
applyExtensionObject(type, data.extensions); | ||
if (data.type === 'object' || data.type === 'interface') { | ||
for (const [fieldName, fieldData] of Object.entries(data.fields)) { | ||
const field = type.getFields()[fieldName]; | ||
if (field) { | ||
applyExtensionObject(field, fieldData.extensions); | ||
for (const [arg, argData] of Object.entries(fieldData.arguments)) { | ||
applyExtensionObject(field.args.find(a => a.name === arg), argData); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
else if (data.type === 'input') { | ||
for (const [fieldName, fieldData] of Object.entries(data.fields)) { | ||
const field = type.getFields()[fieldName]; | ||
applyExtensionObject(field, fieldData.extensions); | ||
else if (data.type === 'input') { | ||
for (const [fieldName, fieldData] of Object.entries(data.fields)) { | ||
const field = type.getFields()[fieldName]; | ||
applyExtensionObject(field, fieldData.extensions); | ||
} | ||
} | ||
} | ||
else if (data.type === 'enum') { | ||
for (const [valueName, valueData] of Object.entries(data.values)) { | ||
const value = type.getValue(valueName); | ||
applyExtensionObject(value, valueData); | ||
else if (data.type === 'enum') { | ||
for (const [valueName, valueData] of Object.entries(data.values)) { | ||
const value = type.getValue(valueName); | ||
applyExtensionObject(value, valueData); | ||
} | ||
} | ||
@@ -912,6 +919,6 @@ } | ||
function makeSchema({ resolvers, typeDefs, extensions, }, config) { | ||
const schema$1 = typeof typeDefs === 'string' ? graphql.buildSchema(typeDefs, config) : graphql.buildASTSchema(typeDefs, config); | ||
let schema$1 = typeof typeDefs === 'string' ? graphql.buildSchema(typeDefs, config) : graphql.buildASTSchema(typeDefs, config); | ||
// add resolvers | ||
if (resolvers) { | ||
schema.addResolversToSchema({ | ||
schema$1 = schema.addResolversToSchema({ | ||
schema: schema$1, | ||
@@ -927,3 +934,3 @@ resolvers, | ||
if (config.logger) { | ||
schema.addErrorLoggingToSchema(schema$1, config.logger); | ||
schema$1 = schema.addErrorLoggingToSchema(schema$1, config.logger); | ||
} | ||
@@ -930,0 +937,0 @@ // use schema directives |
@@ -810,2 +810,5 @@ import { mergeDeep, compareNodes, isNotEqual, printSchemaWithDirectives, createSchemaDefinition, asArray, getResolversFromSchema, SchemaDirectiveVisitor } from '@graphql-tools/utils'; | ||
function applyExtensionObject(obj, extensions) { | ||
if (!obj) { | ||
return; | ||
} | ||
obj.extensions = [obj.extensions || {}, extensions || {}].reduce(mergeDeep, {}); | ||
@@ -817,22 +820,26 @@ } | ||
const type = schema.getType(typeName); | ||
applyExtensionObject(type, data.extensions); | ||
if (data.type === 'object' || data.type === 'interface') { | ||
for (const [fieldName, fieldData] of Object.entries(data.fields)) { | ||
const field = type.getFields()[fieldName]; | ||
applyExtensionObject(field, fieldData.extensions); | ||
for (const [arg, argData] of Object.entries(fieldData.arguments)) { | ||
applyExtensionObject(field.args.find(a => a.name === arg), argData); | ||
if (type) { | ||
applyExtensionObject(type, data.extensions); | ||
if (data.type === 'object' || data.type === 'interface') { | ||
for (const [fieldName, fieldData] of Object.entries(data.fields)) { | ||
const field = type.getFields()[fieldName]; | ||
if (field) { | ||
applyExtensionObject(field, fieldData.extensions); | ||
for (const [arg, argData] of Object.entries(fieldData.arguments)) { | ||
applyExtensionObject(field.args.find(a => a.name === arg), argData); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
else if (data.type === 'input') { | ||
for (const [fieldName, fieldData] of Object.entries(data.fields)) { | ||
const field = type.getFields()[fieldName]; | ||
applyExtensionObject(field, fieldData.extensions); | ||
else if (data.type === 'input') { | ||
for (const [fieldName, fieldData] of Object.entries(data.fields)) { | ||
const field = type.getFields()[fieldName]; | ||
applyExtensionObject(field, fieldData.extensions); | ||
} | ||
} | ||
} | ||
else if (data.type === 'enum') { | ||
for (const [valueName, valueData] of Object.entries(data.values)) { | ||
const value = type.getValue(valueName); | ||
applyExtensionObject(value, valueData); | ||
else if (data.type === 'enum') { | ||
for (const [valueName, valueData] of Object.entries(data.values)) { | ||
const value = type.getValue(valueName); | ||
applyExtensionObject(value, valueData); | ||
} | ||
} | ||
@@ -908,6 +915,6 @@ } | ||
function makeSchema({ resolvers, typeDefs, extensions, }, config) { | ||
const schema = typeof typeDefs === 'string' ? buildSchema(typeDefs, config) : buildASTSchema(typeDefs, config); | ||
let schema = typeof typeDefs === 'string' ? buildSchema(typeDefs, config) : buildASTSchema(typeDefs, config); | ||
// add resolvers | ||
if (resolvers) { | ||
addResolversToSchema({ | ||
schema = addResolversToSchema({ | ||
schema, | ||
@@ -923,3 +930,3 @@ resolvers, | ||
if (config.logger) { | ||
addErrorLoggingToSchema(schema, config.logger); | ||
schema = addErrorLoggingToSchema(schema, config.logger); | ||
} | ||
@@ -926,0 +933,0 @@ // use schema directives |
{ | ||
"name": "@graphql-tools/merge", | ||
"version": "6.0.0-alpha.1", | ||
"version": "6.0.0-alpha-08f96bd.0", | ||
"description": "A set of utils for faster development of GraphQL tools", | ||
@@ -9,5 +9,5 @@ "peerDependencies": { | ||
"dependencies": { | ||
"@graphql-tools/schema": "6.0.0-alpha.1", | ||
"@graphql-tools/utils": "6.0.0-alpha.1", | ||
"tslib": "1.11.1" | ||
"@graphql-tools/schema": "6.0.0-alpha-08f96bd.0", | ||
"@graphql-tools/utils": "6.0.0-alpha-08f96bd.0", | ||
"tslib": "~2.0.0" | ||
}, | ||
@@ -14,0 +14,0 @@ "repository": "git@github.com:ardatan/graphql-tools.git", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
264493
2130
+ Added@graphql-tools/schema@6.0.0-alpha-08f96bd.0(transitive)
+ Added@graphql-tools/utils@6.0.0-alpha-08f96bd.0(transitive)
+ Addedtslib@1.14.12.0.3(transitive)
- Removed@graphql-tools/schema@6.0.0-alpha.1(transitive)
- Removed@graphql-tools/utils@6.0.0-alpha.1(transitive)
- Removedtslib@1.11.12.6.3(transitive)
Updatedtslib@~2.0.0