Skip to content

Commit b48a91b

Browse files
authored
Stitching Directives (#2227)
Release alpha version of stitching directives that allows directive annotated subschemas, so that merge configuration can be more automated.
1 parent ca440b7 commit b48a91b

28 files changed

+2491
-16
lines changed

.changeset/old-apples-remain.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
'@graphql-tools/stitching-directives': patch
3+
'@graphql-tools/schema': patch
4+
'@graphql-tools/stitch': patch
5+
'@graphql-tools/utils': patch
6+
---
7+
8+
add ability to specify merge config within subschemas using directives

packages/schema/src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,4 @@ export interface IExecutableSchemaDefinition<TContext = any> {
7777
noExtensionExtraction?: boolean;
7878
}
7979

80-
export type ExecutableSchemaTransformation = (originalWrappingSchema: GraphQLSchema) => GraphQLSchema;
80+
export type ExecutableSchemaTransformation = (schema: GraphQLSchema) => GraphQLSchema;

packages/stitch/src/isolateComputedFields.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,15 @@ function filterBaseSubschema(
5959
subschemaConfig: SubschemaConfig,
6060
isolatedSchemaTypes: Record<string, MergedTypeConfig>
6161
): SubschemaConfig {
62+
const schema = subschemaConfig.schema;
6263
const typesForInterface: Record<string, string[]> = {};
6364
const filteredSchema = pruneSchema(
6465
filterSchema({
65-
schema: subschemaConfig.schema,
66+
schema,
6667
objectFieldFilter: (typeName, fieldName) => !isolatedSchemaTypes[typeName]?.fields[fieldName],
6768
interfaceFieldFilter: (typeName, fieldName) => {
6869
if (!typesForInterface[typeName]) {
69-
typesForInterface[typeName] = getImplementingTypes(typeName, subschemaConfig.schema);
70+
typesForInterface[typeName] = getImplementingTypes(typeName, schema);
7071
}
7172
return !typesForInterface[typeName].some(
7273
implementingTypeName => isolatedSchemaTypes[implementingTypeName]?.fields[fieldName]

0 commit comments

Comments
 (0)