@graphql-toolkit/core
Advanced tools
Comparing version 0.10.5-alpha-cf8673b.10 to 0.10.5-alpha-d943f3a.11
@@ -1165,12 +1165,3 @@ 'use strict'; | ||
}); | ||
const schemas = []; | ||
const typeDefs = []; | ||
sources.forEach(source => { | ||
if (source.schema) { | ||
schemas.push(source.schema); | ||
} | ||
else { | ||
typeDefs.push(source.document); | ||
} | ||
}); | ||
const { schemas, typeDefs } = collectSchemasAndTypeDefs(sources); | ||
const mergeSchemasOptions = { | ||
@@ -1181,3 +1172,7 @@ schemas, | ||
}; | ||
return schemaMerging.mergeSchemasAsync(mergeSchemasOptions); | ||
const schema = await schemaMerging.mergeSchemasAsync(mergeSchemasOptions); | ||
if (options.includeSources) { | ||
includeSources(schema, sources); | ||
} | ||
return schema; | ||
} | ||
@@ -1189,5 +1184,24 @@ function loadSchemaSync(schemaPointers, options) { | ||
}); | ||
const { schemas, typeDefs } = collectSchemasAndTypeDefs(sources); | ||
const mergeSchemasOptions = { | ||
schemas, | ||
typeDefs, | ||
...options, | ||
}; | ||
const schema = schemaMerging.mergeSchemas(mergeSchemasOptions); | ||
if (options.includeSources) { | ||
includeSources(schema, sources); | ||
} | ||
return schema; | ||
} | ||
function includeSources(schema, sources) { | ||
schema.extensions = { | ||
...schema.extensions, | ||
sources, | ||
}; | ||
} | ||
function collectSchemasAndTypeDefs(sources) { | ||
const schemas = []; | ||
const typeDefs = []; | ||
sources.forEach(source => { | ||
sources.forEach((source) => { | ||
if (source.schema) { | ||
@@ -1200,8 +1214,6 @@ schemas.push(source.schema); | ||
}); | ||
const mergeSchemasOptions = { | ||
return { | ||
schemas, | ||
typeDefs, | ||
...options, | ||
}; | ||
return schemaMerging.mergeSchemas(mergeSchemasOptions); | ||
} | ||
@@ -1208,0 +1220,0 @@ |
@@ -1140,12 +1140,3 @@ import { asArray, resolveBuiltinModule, resolveBuiltinModuleSync, debugLog, printSchemaWithDirectives, isDocumentString, parseGraphQLSDL, compareNodes, fixSchemaAst, compareStrings } from '@graphql-toolkit/common'; | ||
}); | ||
const schemas = []; | ||
const typeDefs = []; | ||
sources.forEach(source => { | ||
if (source.schema) { | ||
schemas.push(source.schema); | ||
} | ||
else { | ||
typeDefs.push(source.document); | ||
} | ||
}); | ||
const { schemas, typeDefs } = collectSchemasAndTypeDefs(sources); | ||
const mergeSchemasOptions = { | ||
@@ -1156,3 +1147,7 @@ schemas, | ||
}; | ||
return mergeSchemasAsync(mergeSchemasOptions); | ||
const schema = await mergeSchemasAsync(mergeSchemasOptions); | ||
if (options.includeSources) { | ||
includeSources(schema, sources); | ||
} | ||
return schema; | ||
} | ||
@@ -1164,5 +1159,24 @@ function loadSchemaSync(schemaPointers, options) { | ||
}); | ||
const { schemas, typeDefs } = collectSchemasAndTypeDefs(sources); | ||
const mergeSchemasOptions = { | ||
schemas, | ||
typeDefs, | ||
...options, | ||
}; | ||
const schema = mergeSchemas(mergeSchemasOptions); | ||
if (options.includeSources) { | ||
includeSources(schema, sources); | ||
} | ||
return schema; | ||
} | ||
function includeSources(schema, sources) { | ||
schema.extensions = { | ||
...schema.extensions, | ||
sources, | ||
}; | ||
} | ||
function collectSchemasAndTypeDefs(sources) { | ||
const schemas = []; | ||
const typeDefs = []; | ||
sources.forEach(source => { | ||
sources.forEach((source) => { | ||
if (source.schema) { | ||
@@ -1175,8 +1189,6 @@ schemas.push(source.schema); | ||
}); | ||
const mergeSchemasOptions = { | ||
return { | ||
schemas, | ||
typeDefs, | ||
...options, | ||
}; | ||
return mergeSchemas(mergeSchemasOptions); | ||
} | ||
@@ -1183,0 +1195,0 @@ |
{ | ||
"name": "@graphql-toolkit/core", | ||
"version": "0.10.5-alpha-cf8673b.10+cf8673b", | ||
"version": "0.10.5-alpha-d943f3a.11+d943f3a", | ||
"description": "A set of utils for faster development of GraphQL tools", | ||
@@ -9,4 +9,4 @@ "peerDependencies": { | ||
"dependencies": { | ||
"@graphql-toolkit/common": "0.10.5-alpha-cf8673b.10+cf8673b", | ||
"@graphql-toolkit/schema-merging": "0.10.5-alpha-cf8673b.10+cf8673b", | ||
"@graphql-toolkit/common": "0.10.5-alpha-d943f3a.11+d943f3a", | ||
"@graphql-toolkit/schema-merging": "0.10.5-alpha-d943f3a.11+d943f3a", | ||
"aggregate-error": "3.0.1", | ||
@@ -13,0 +13,0 @@ "globby": "11.0.0", |
import { LoadTypedefsOptions, UnnormalizedTypeDefPointer } from './load-typedefs'; | ||
import { GraphQLSchema, BuildSchemaOptions } from 'graphql'; | ||
import { MergeSchemasConfig } from '@graphql-toolkit/schema-merging'; | ||
export declare type LoadSchemaOptions = BuildSchemaOptions & LoadTypedefsOptions & Partial<MergeSchemasConfig>; | ||
export declare type LoadSchemaOptions = BuildSchemaOptions & LoadTypedefsOptions & Partial<MergeSchemasConfig> & { | ||
/** | ||
* Adds a list of Source objects in to `extensions.sources` | ||
* | ||
* Disabled by default. | ||
*/ | ||
includeSources?: boolean; | ||
}; | ||
export declare function loadSchema(schemaPointers: UnnormalizedTypeDefPointer | UnnormalizedTypeDefPointer[], options: LoadSchemaOptions): Promise<GraphQLSchema>; | ||
export declare function loadSchemaSync(schemaPointers: UnnormalizedTypeDefPointer | UnnormalizedTypeDefPointer[], options: LoadSchemaOptions): GraphQLSchema; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
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
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
275793
2611