@graphql-tools/schema 8.3.10 → 9.0.0-alpha-7172a2c3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/addResolversToSchema.d.ts +2 -2
- package/index.js +24 -22
- package/index.mjs +25 -23
- package/makeExecutableSchema.d.ts +3 -4
- package/merge-schemas.d.ts +1 -1
- package/package.json +4 -4
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { GraphQLSchema } from 'graphql';
|
|
2
|
-
import {
|
|
3
|
-
export declare function addResolversToSchema(
|
|
2
|
+
import { IAddResolversToSchemaOptions } from '@graphql-tools/utils';
|
|
3
|
+
export declare function addResolversToSchema({ schema, resolvers: inputResolvers, defaultFieldResolver, resolverValidationOptions, inheritResolversFromInterfaces, updateResolversInPlace, }: IAddResolversToSchemaOptions): GraphQLSchema;
|
package/index.js
CHANGED
|
@@ -108,15 +108,7 @@ function extendResolversFromInterfaces(schema, resolvers) {
|
|
|
108
108
|
return extendedResolvers;
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
-
function addResolversToSchema(
|
|
112
|
-
const options = graphql.isSchema(schemaOrOptions)
|
|
113
|
-
? {
|
|
114
|
-
schema: schemaOrOptions,
|
|
115
|
-
resolvers: legacyInputResolvers !== null && legacyInputResolvers !== void 0 ? legacyInputResolvers : {},
|
|
116
|
-
resolverValidationOptions: legacyInputValidationOptions,
|
|
117
|
-
}
|
|
118
|
-
: schemaOrOptions;
|
|
119
|
-
let { schema, resolvers: inputResolvers, defaultFieldResolver, resolverValidationOptions = {}, inheritResolversFromInterfaces = false, updateResolversInPlace = false, } = options;
|
|
111
|
+
function addResolversToSchema({ schema, resolvers: inputResolvers, defaultFieldResolver, resolverValidationOptions = {}, inheritResolversFromInterfaces = false, updateResolversInPlace = false, }) {
|
|
120
112
|
const { requireResolversToMatchSchema = 'error', requireResolversForResolveType } = resolverValidationOptions;
|
|
121
113
|
const resolvers = inheritResolversFromInterfaces
|
|
122
114
|
? extendResolversFromInterfaces(schema, inputResolvers)
|
|
@@ -435,12 +427,11 @@ function setFieldProperties(field, propertiesObj) {
|
|
|
435
427
|
* of these. If a function is provided, it will be passed no arguments and
|
|
436
428
|
* should return an array of strings or `DocumentNode`s.
|
|
437
429
|
*
|
|
438
|
-
* Note: You can use
|
|
439
|
-
*
|
|
440
|
-
* editor (with the appropriate editor plugin).
|
|
430
|
+
* Note: You can use GraphQL magic comment provide additional syntax
|
|
431
|
+
* highlighting in your editor (with the appropriate editor plugin).
|
|
441
432
|
*
|
|
442
433
|
* ```js
|
|
443
|
-
* const typeDefs =
|
|
434
|
+
* const typeDefs = /* GraphQL *\/ `
|
|
444
435
|
* type Query {
|
|
445
436
|
* posts: [Post]
|
|
446
437
|
* author(id: Int!): Author
|
|
@@ -520,17 +511,28 @@ function makeExecutableSchema({ typeDefs, resolvers = {}, resolverValidationOpti
|
|
|
520
511
|
* @param config Configuration object
|
|
521
512
|
*/
|
|
522
513
|
function mergeSchemas(config) {
|
|
523
|
-
const extractedTypeDefs =
|
|
524
|
-
const extractedResolvers =
|
|
525
|
-
const extractedSchemaExtensions =
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
514
|
+
const extractedTypeDefs = [];
|
|
515
|
+
const extractedResolvers = [];
|
|
516
|
+
const extractedSchemaExtensions = [];
|
|
517
|
+
if (config.schemas != null) {
|
|
518
|
+
for (const schema of config.schemas) {
|
|
519
|
+
extractedTypeDefs.push(schema);
|
|
520
|
+
extractedResolvers.push(utils.getResolversFromSchema(schema));
|
|
521
|
+
extractedSchemaExtensions.push(merge.extractExtensionsFromSchema(schema));
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
if (config.typeDefs != null) {
|
|
525
|
+
extractedTypeDefs.push(config.typeDefs);
|
|
526
|
+
}
|
|
527
|
+
if (config.resolvers != null) {
|
|
528
|
+
const additionalResolvers = utils.asArray(config.resolvers);
|
|
529
|
+
extractedResolvers.push(...additionalResolvers);
|
|
530
|
+
}
|
|
531
|
+
if (config.schemaExtensions != null) {
|
|
532
|
+
const additionalSchemaExtensions = utils.asArray(config.schemaExtensions);
|
|
533
|
+
extractedSchemaExtensions.push(...additionalSchemaExtensions);
|
|
531
534
|
}
|
|
532
535
|
return makeExecutableSchema({
|
|
533
|
-
parseOptions: config,
|
|
534
536
|
...config,
|
|
535
537
|
typeDefs: extractedTypeDefs,
|
|
536
538
|
resolvers: extractedResolvers,
|
package/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isScalarType, getNamedType, defaultFieldResolver,
|
|
1
|
+
import { isScalarType, getNamedType, defaultFieldResolver, isSpecifiedScalarType, isEnumType, isUnionType, isObjectType, isInterfaceType, GraphQLEnumType, GraphQLScalarType, GraphQLUnionType, GraphQLObjectType, GraphQLInterfaceType, isSchema, buildSchema, buildASTSchema } from 'graphql';
|
|
2
2
|
import { forEachField, mapSchema, MapperKind, forEachDefaultValue, serializeInputValue, healSchema, parseInputValue, pruneSchema, asArray, getResolversFromSchema } from '@graphql-tools/utils';
|
|
3
3
|
import { mergeTypeDefs, mergeResolvers, mergeExtensions, applyExtensions, extractExtensionsFromSchema } from '@graphql-tools/merge';
|
|
4
4
|
|
|
@@ -104,15 +104,7 @@ function extendResolversFromInterfaces(schema, resolvers) {
|
|
|
104
104
|
return extendedResolvers;
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
-
function addResolversToSchema(
|
|
108
|
-
const options = isSchema(schemaOrOptions)
|
|
109
|
-
? {
|
|
110
|
-
schema: schemaOrOptions,
|
|
111
|
-
resolvers: legacyInputResolvers !== null && legacyInputResolvers !== void 0 ? legacyInputResolvers : {},
|
|
112
|
-
resolverValidationOptions: legacyInputValidationOptions,
|
|
113
|
-
}
|
|
114
|
-
: schemaOrOptions;
|
|
115
|
-
let { schema, resolvers: inputResolvers, defaultFieldResolver, resolverValidationOptions = {}, inheritResolversFromInterfaces = false, updateResolversInPlace = false, } = options;
|
|
107
|
+
function addResolversToSchema({ schema, resolvers: inputResolvers, defaultFieldResolver, resolverValidationOptions = {}, inheritResolversFromInterfaces = false, updateResolversInPlace = false, }) {
|
|
116
108
|
const { requireResolversToMatchSchema = 'error', requireResolversForResolveType } = resolverValidationOptions;
|
|
117
109
|
const resolvers = inheritResolversFromInterfaces
|
|
118
110
|
? extendResolversFromInterfaces(schema, inputResolvers)
|
|
@@ -431,12 +423,11 @@ function setFieldProperties(field, propertiesObj) {
|
|
|
431
423
|
* of these. If a function is provided, it will be passed no arguments and
|
|
432
424
|
* should return an array of strings or `DocumentNode`s.
|
|
433
425
|
*
|
|
434
|
-
* Note: You can use
|
|
435
|
-
*
|
|
436
|
-
* editor (with the appropriate editor plugin).
|
|
426
|
+
* Note: You can use GraphQL magic comment provide additional syntax
|
|
427
|
+
* highlighting in your editor (with the appropriate editor plugin).
|
|
437
428
|
*
|
|
438
429
|
* ```js
|
|
439
|
-
* const typeDefs =
|
|
430
|
+
* const typeDefs = /* GraphQL *\/ `
|
|
440
431
|
* type Query {
|
|
441
432
|
* posts: [Post]
|
|
442
433
|
* author(id: Int!): Author
|
|
@@ -516,17 +507,28 @@ function makeExecutableSchema({ typeDefs, resolvers = {}, resolverValidationOpti
|
|
|
516
507
|
* @param config Configuration object
|
|
517
508
|
*/
|
|
518
509
|
function mergeSchemas(config) {
|
|
519
|
-
const extractedTypeDefs =
|
|
520
|
-
const extractedResolvers =
|
|
521
|
-
const extractedSchemaExtensions =
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
510
|
+
const extractedTypeDefs = [];
|
|
511
|
+
const extractedResolvers = [];
|
|
512
|
+
const extractedSchemaExtensions = [];
|
|
513
|
+
if (config.schemas != null) {
|
|
514
|
+
for (const schema of config.schemas) {
|
|
515
|
+
extractedTypeDefs.push(schema);
|
|
516
|
+
extractedResolvers.push(getResolversFromSchema(schema));
|
|
517
|
+
extractedSchemaExtensions.push(extractExtensionsFromSchema(schema));
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
if (config.typeDefs != null) {
|
|
521
|
+
extractedTypeDefs.push(config.typeDefs);
|
|
522
|
+
}
|
|
523
|
+
if (config.resolvers != null) {
|
|
524
|
+
const additionalResolvers = asArray(config.resolvers);
|
|
525
|
+
extractedResolvers.push(...additionalResolvers);
|
|
526
|
+
}
|
|
527
|
+
if (config.schemaExtensions != null) {
|
|
528
|
+
const additionalSchemaExtensions = asArray(config.schemaExtensions);
|
|
529
|
+
extractedSchemaExtensions.push(...additionalSchemaExtensions);
|
|
527
530
|
}
|
|
528
531
|
return makeExecutableSchema({
|
|
529
|
-
parseOptions: config,
|
|
530
532
|
...config,
|
|
531
533
|
typeDefs: extractedTypeDefs,
|
|
532
534
|
resolvers: extractedResolvers,
|
|
@@ -8,12 +8,11 @@ import { IExecutableSchemaDefinition } from './types';
|
|
|
8
8
|
* of these. If a function is provided, it will be passed no arguments and
|
|
9
9
|
* should return an array of strings or `DocumentNode`s.
|
|
10
10
|
*
|
|
11
|
-
* Note: You can use
|
|
12
|
-
*
|
|
13
|
-
* editor (with the appropriate editor plugin).
|
|
11
|
+
* Note: You can use GraphQL magic comment provide additional syntax
|
|
12
|
+
* highlighting in your editor (with the appropriate editor plugin).
|
|
14
13
|
*
|
|
15
14
|
* ```js
|
|
16
|
-
* const typeDefs =
|
|
15
|
+
* const typeDefs = /* GraphQL *\/ `
|
|
17
16
|
* type Query {
|
|
18
17
|
* posts: [Post]
|
|
19
18
|
* author(id: Int!): Author
|
package/merge-schemas.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { IExecutableSchemaDefinition } from './types';
|
|
|
3
3
|
/**
|
|
4
4
|
* Configuration object for schema merging
|
|
5
5
|
*/
|
|
6
|
-
export declare type MergeSchemasConfig<T = any> = Partial<IExecutableSchemaDefinition<T>> &
|
|
6
|
+
export declare type MergeSchemasConfig<T = any> = Partial<IExecutableSchemaDefinition<T>> & {
|
|
7
7
|
/**
|
|
8
8
|
* The schemas to be merged
|
|
9
9
|
*/
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-tools/schema",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "9.0.0-alpha-7172a2c3.0",
|
|
4
4
|
"description": "A set of utils for faster development of GraphQL tools",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"peerDependencies": {
|
|
7
7
|
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@graphql-tools/merge": "8.2.
|
|
11
|
-
"@graphql-tools/utils": "8.6.
|
|
12
|
-
"tslib": "~2.
|
|
10
|
+
"@graphql-tools/merge": "8.2.11",
|
|
11
|
+
"@graphql-tools/utils": "8.6.10",
|
|
12
|
+
"tslib": "~2.4.0",
|
|
13
13
|
"value-or-promise": "1.0.11"
|
|
14
14
|
},
|
|
15
15
|
"repository": {
|