Closed DonnyVerduijn closed 3 years ago
My preference would go out to hide fields from resolvers that are decorated with ResolveField by default, unless they are explicitly added to the object type.
There's no plan to change the default behavior.
Alternatives would be to either create an additional Decorator for stub resolvers, allow the field to be hidden through its configuration options or through an additional decorator such as HideField that would apply the @internal directive in case of stub resolvers. However i think it's best to make this feature opt-in instead of opt-out.
Adding a configuration property that would allow flagging a specific resolver as "internal" sounds interesting. Would you like to create a PR for this issue?
Hi Kamil, after giving it a second thought, i agree it would be unwise to change the default behavior. I guess it's best to wait for apollo its implementation of the @internal
directive as stated in https://github.com/apollographql/federation/issues/371, before we look further into this?
Sounds good to me 👍 Let's wait then
I'm submitting a...
Current behavior
When using federated graphs, it seems to be impossible to avoid that stub resolvers that are decorated with the ResolveField decorator, create extra fields on the object type. For example, when a user has an accounts property with an array of accounts, every account has a field
user
that references back to the user in question.Expected behavior
My preference would go out to hide fields from resolvers that are decorated with ResolveField by default, unless they are explicitly added to the object type.
Alternatives would be to either create an additional Decorator for stub resolvers, allow the field to be hidden through its configuration options or through an additional decorator such as HideField that would apply the @internal directive in case of stub resolvers. However i think it's best to make this feature opt-in instead of opt-out.
Minimal reproduction of the problem with instructions
https://github.com/hardyscc/nestjs-cqrs-starter ./apps/service-account/src/account/resolver/account.resolver.ts
This adds the user field to the accounts object type, but cannot be removed since it is required for federated graphs to resolve accounts in parallel with the user.
What is the motivation / use case for changing the behavior?
The reason why this is such a problem, is that it creates circular references in the graph which should be avoided by default. It also unexpectedly exposes fields where this might be unwanted.
Environment