-
-
Notifications
You must be signed in to change notification settings - Fork 833
Description
As of now when trying to use certain transformers as part of delegateToSchema they will fail as the underlying MapFields requires transformSchema to be called (and delegateToSchema only calls the operational parts of the transform). Namely we were trying to leverage HoistField when extending schema as part of a graphql mesh setup.
To Reproduce
- Setup a graphql schema + resolvers
- Use
delegateToSchemain one of the resolvers - Use
HoistFieldas a transform in thedelegateToSchemacall - Execution will fail as
transformSchemahas not been called
Looking at the code, the only reason transformers is not initialized as part of the constructor is the need to know the name of the Subscription type:
| typeName = subscriptionTypeName; |
Key Question:
Is there any way the above can be avoided or structured differently so we can use transforms that rely on MapFields when using delegateToSchema?
Expected behavior
- Transforms should initialize correctly independent from calling
transformSchema - Since
MapFieldsis used in many of them it would make sense to remove the dependency ontransformSchemabeing called first. - This way they can be used as transforms in
delegateToSchemacalls
Environment:
@graphql-tools/[email protected]
Additional context
As of right now we are creating an instance of hoist field and call transformSchema manually before passing the instance into the delegateToSchema transforms array. It does work, but is obviously not the original intend. In addition it hurts performance as I happens each time the resolver is called.