@graphql-tools/delegate
Version:
A set of utils for faster development of GraphQL tools
10 lines (9 loc) • 546 B
JavaScript
import { memoize2 } from '@graphql-tools/utils';
// TODO: Instead of memoization, we can make sure that this isn't called multiple times
export const applySchemaTransforms = memoize2(function applySchemaTransforms(originalWrappingSchema, subschemaConfig) {
const schemaTransforms = subschemaConfig.transforms;
if (schemaTransforms == null) {
return originalWrappingSchema;
}
return schemaTransforms.reduce((schema, transform) => transform.transformSchema?.(schema, subschemaConfig) || schema, originalWrappingSchema);
});