Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve Stitched Schema generation (#4566)
* Avoid transformedSchema * Cleanup * More * Go * Cleanup * Remove 'computedFields' * Less diff * More * Memoize applySchemaTransforms
- Loading branch information
Showing
48 changed files
with
290 additions
and
427 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
--- | ||
'@graphql-tools/delegate': major | ||
'@graphql-tools/wrap': major | ||
--- | ||
|
||
Breaking changes; | ||
|
||
**Schema generation optimization by removing `transfomedSchema` parameter** | ||
|
||
Previously we were applying the transforms multiple times. We needed to introduced some breaking changes to improve the initial wrapped/stitched schema generation performance; | ||
|
||
- `Transform.transformSchema` no longer accepts `transformedSchema` which can easily be created with `applySchemaTransforms(schema, subschemaConfig)` instead. | ||
- Proxying resolver factory function that is passed as `createProxyingResolver` to `SubschemaConfig` no longer takes `transformedSchema` which can easily be created with `applySchemaTransforms(schema, subschemaConfig)` instead. | ||
|
||
**`stitchSchemas` doesn't take nested arrays of subschemas** | ||
|
||
`stitchSchemas` no longer accepts an array of arrays of subschema configuration objects. Instead, it accepts an array of subschema configuration objects or schema objects directly. | ||
|
||
**`stitchSchemas` no longer prunes the schema with `pruningOptions`** | ||
|
||
You can use `pruneSchema` from `@graphql-tools/utils` to prune the schema instead. | ||
|
||
**`stitchSchemas` no longer respect "@computed" directive if stitchingDirectivesTransformer isn't applied** | ||
|
||
Also `@graphql-tools/stitch` no longer exports `computedDirectiveTransformer` and `defaultSubschemaConfigTransforms`. | ||
Instead, use `@graphql-tools/stitching-directives` package for `@computed` directive. | ||
[Learn more about setting it up](https://www.graphql-tools.com/docs/schema-stitching/stitch-directives-sdl#directives-glossary) | ||
|
||
**`computedFields` has been removed from the merged type configuration** | ||
|
||
`MergeTypeConfig.computedFields` setting has been removed in favor of new computed field configuration written as: | ||
|
||
```js | ||
merge: { | ||
MyType: { | ||
fields: { | ||
myComputedField: { | ||
selectionSet: '{ weight }', | ||
computed: true, | ||
} | ||
} | ||
} | ||
} | ||
``` | ||
|
||
A field-level `selectionSet` specifies field dependencies while the `computed` setting structures the field in a way that assures it is always selected with this data provided. The `selectionSet` is intentionally generic to support possible future uses. This new pattern organizes all field-level configuration (including `canonical`) into a single structure. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 0 additions & 43 deletions
43
packages/stitch/src/subschemaConfigTransforms/computedDirectiveTransformer.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,2 @@ | ||
import { SubschemaConfigTransform } from '../types.js'; | ||
import { computedDirectiveTransformer } from './computedDirectiveTransformer.js'; | ||
|
||
export { computedDirectiveTransformer } from './computedDirectiveTransformer.js'; | ||
export { isolateComputedFieldsTransformer } from './isolateComputedFieldsTransformer.js'; | ||
export { splitMergedTypeEntryPointsTransformer } from './splitMergedTypeEntryPointsTransformer.js'; | ||
|
||
export const defaultSubschemaConfigTransforms: Array<SubschemaConfigTransform<any>> = [ | ||
computedDirectiveTransformer('computed'), | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.