@graphql-tools/stitching-directives 3.1.33-alpha-3fb8d587b41638f428d90309c8cf2dcd31edc8e3 → 3.1.33-alpha-e560e81bbe455149c724fd221bb562deb48a018f
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/CHANGELOG.md +5 -3
- package/dist/index.cjs +12 -12
- package/dist/index.js +2 -2
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
@@ -1,11 +1,13 @@
|
|
1
1
|
# @graphql-tools/stitching-directives
|
2
2
|
|
3
|
-
## 3.1.33-alpha-
|
3
|
+
## 3.1.33-alpha-e560e81bbe455149c724fd221bb562deb48a018f
|
4
4
|
|
5
5
|
### Patch Changes
|
6
6
|
|
7
|
-
-
|
8
|
-
|
7
|
+
- [#1108](https://github.com/graphql-hive/gateway/pull/1108) [`e560e81`](https://github.com/graphql-hive/gateway/commit/e560e81bbe455149c724fd221bb562deb48a018f) Thanks [@ardatan](https://github.com/ardatan)! - Avoid `instanceOf` checks for `isXType` checkers
|
8
|
+
|
9
|
+
- Updated dependencies [[`e560e81`](https://github.com/graphql-hive/gateway/commit/e560e81bbe455149c724fd221bb562deb48a018f)]:
|
10
|
+
- @graphql-tools/delegate@10.2.18-alpha-e560e81bbe455149c724fd221bb562deb48a018f
|
9
11
|
|
10
12
|
## 3.1.32
|
11
13
|
|
package/dist/index.cjs
CHANGED
@@ -552,7 +552,7 @@ function stitchingDirectivesTransformer(options = {}) {
|
|
552
552
|
)?.[0];
|
553
553
|
if (mergeDirective != null) {
|
554
554
|
const returnType = graphql.getNullableType(fieldConfig.type);
|
555
|
-
const returnsList =
|
555
|
+
const returnsList = delegate.isListType(returnType);
|
556
556
|
const namedType = graphql.getNamedType(returnType);
|
557
557
|
let mergeArgsExpr = mergeDirective["argsExpr"];
|
558
558
|
if (mergeArgsExpr == null) {
|
@@ -732,19 +732,19 @@ function stitchingDirectivesTransformer(options = {}) {
|
|
732
732
|
};
|
733
733
|
}
|
734
734
|
function forEachConcreteType(schema, type, typeNames, fn) {
|
735
|
-
if (
|
735
|
+
if (delegate.isInterfaceType(type)) {
|
736
736
|
for (const typeName of utils.getImplementingTypes(type.name, schema)) {
|
737
737
|
if (typeNames == null || typeNames.includes(typeName)) {
|
738
738
|
fn(typeName);
|
739
739
|
}
|
740
740
|
}
|
741
|
-
} else if (
|
741
|
+
} else if (delegate.isUnionType(type)) {
|
742
742
|
for (const { name: typeName } of type.getTypes()) {
|
743
743
|
if (typeNames == null || typeNames.includes(typeName)) {
|
744
744
|
fn(typeName);
|
745
745
|
}
|
746
746
|
}
|
747
|
-
} else if (
|
747
|
+
} else if (delegate.isObjectType(type)) {
|
748
748
|
fn(type.name);
|
749
749
|
}
|
750
750
|
}
|
@@ -840,19 +840,19 @@ function mergeSelectionSets(...selectionSets) {
|
|
840
840
|
return newSelectionSet;
|
841
841
|
}
|
842
842
|
function forEachConcreteTypeName(returnType, schema, typeNames, fn) {
|
843
|
-
if (
|
843
|
+
if (delegate.isInterfaceType(returnType)) {
|
844
844
|
for (const typeName of utils.getImplementingTypes(returnType.name, schema)) {
|
845
845
|
if (typeNames == null || typeNames.includes(typeName)) {
|
846
846
|
fn(typeName);
|
847
847
|
}
|
848
848
|
}
|
849
|
-
} else if (
|
849
|
+
} else if (delegate.isUnionType(returnType)) {
|
850
850
|
for (const type of returnType.getTypes()) {
|
851
851
|
if (typeNames == null || typeNames.includes(type.name)) {
|
852
852
|
fn(type.name);
|
853
853
|
}
|
854
854
|
}
|
855
|
-
} else if (
|
855
|
+
} else if (delegate.isObjectType(returnType) && (typeNames == null || typeNames.includes(returnType.name))) {
|
856
856
|
fn(returnType.name);
|
857
857
|
}
|
858
858
|
}
|
@@ -906,10 +906,10 @@ function stitchingDirectivesValidator(options = {}) {
|
|
906
906
|
);
|
907
907
|
}
|
908
908
|
let returnType = graphql.getNullableType(fieldConfig.type);
|
909
|
-
if (
|
909
|
+
if (delegate.isListType(returnType)) {
|
910
910
|
returnType = graphql.getNullableType(returnType.ofType);
|
911
911
|
}
|
912
|
-
if (!
|
912
|
+
if (!delegate.isNamedType(returnType)) {
|
913
913
|
throw new Error(
|
914
914
|
"@merge directive must be used on a field that returns an object or a list of objects."
|
915
915
|
);
|
@@ -973,19 +973,19 @@ function stitchingDirectivesValidator(options = {}) {
|
|
973
973
|
"Cannot use @merge directive with both `argsExpr` argument and any additional argument."
|
974
974
|
);
|
975
975
|
}
|
976
|
-
if (!
|
976
|
+
if (!delegate.isInterfaceType(returnType) && !delegate.isUnionType(returnType) && !delegate.isObjectType(returnType)) {
|
977
977
|
throw new Error(
|
978
978
|
"@merge directive may be used only with resolver that return an object, interface, or union."
|
979
979
|
);
|
980
980
|
}
|
981
981
|
const typeNames = mergeDirective["types"];
|
982
982
|
if (typeNames != null) {
|
983
|
-
if (!
|
983
|
+
if (!delegate.isAbstractType(returnType)) {
|
984
984
|
throw new Error(
|
985
985
|
"Types argument can only be used with a field that returns an abstract type."
|
986
986
|
);
|
987
987
|
}
|
988
|
-
const implementingTypes =
|
988
|
+
const implementingTypes = delegate.isInterfaceType(returnType) ? utils.getImplementingTypes(returnType.name, schema).map(
|
989
989
|
(typeName2) => schema.getType(typeName2)
|
990
990
|
) : returnType.getTypes();
|
991
991
|
const implementingTypeNames = implementingTypes.map((type) => type?.name).filter(utils.isSome);
|
package/dist/index.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
import { visit, Kind, TypeNameMetaFieldDef, parseValue, valueFromASTUntyped, getNamedType, getNullableType,
|
2
|
-
import { cloneSubschemaConfig } from '@graphql-tools/delegate';
|
1
|
+
import { visit, Kind, TypeNameMetaFieldDef, parseValue, valueFromASTUntyped, getNamedType, getNullableType, print, GraphQLDirective, GraphQLNonNull, GraphQLString, GraphQLList, parse } from 'graphql';
|
2
|
+
import { cloneSubschemaConfig, isListType, isInterfaceType, isUnionType, isObjectType, isNamedType, isAbstractType } from '@graphql-tools/delegate';
|
3
3
|
import { mapSchema, MapperKind, getDirective, parseSelectionSet, getImplementingTypes, mergeDeep, isSome } from '@graphql-tools/utils';
|
4
4
|
|
5
5
|
const defaultStitchingDirectiveOptions = {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@graphql-tools/stitching-directives",
|
3
|
-
"version": "3.1.33-alpha-
|
3
|
+
"version": "3.1.33-alpha-e560e81bbe455149c724fd221bb562deb48a018f",
|
4
4
|
"type": "module",
|
5
5
|
"description": "A set of utils for faster development of GraphQL tools",
|
6
6
|
"repository": {
|
@@ -38,14 +38,14 @@
|
|
38
38
|
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0"
|
39
39
|
},
|
40
40
|
"dependencies": {
|
41
|
-
"@graphql-tools/delegate": "10.2.18-alpha-
|
41
|
+
"@graphql-tools/delegate": "10.2.18-alpha-e560e81bbe455149c724fd221bb562deb48a018f",
|
42
42
|
"@graphql-tools/utils": "^10.8.1",
|
43
43
|
"tslib": "^2.8.1"
|
44
44
|
},
|
45
45
|
"devDependencies": {
|
46
46
|
"@graphql-tools/schema": "^10.0.11",
|
47
47
|
"graphql": "^16.9.0",
|
48
|
-
"pkgroll": "2.12.
|
48
|
+
"pkgroll": "2.12.2"
|
49
49
|
},
|
50
50
|
"sideEffects": false
|
51
51
|
}
|