You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey guys, so I'm working with the federation features and I'm stuck when trying to access my dependencies from the populates requires method.
Is this possible?
My populate requires look something like this:
exec/federation.requires.go
func (ec *executionContext) PopulateSampleTypeRequires(ctx context.Context, entity *model.ModelSample, reps map[string]interface{}) error {
plugin, err := ParsePlugin(reps)
// Here I want to call my resolver dependency
ec.resolvers.(*resolver.Resolver).Svc.DoSomething()
}
resolver/resolver.go
type PluginService interface {
DoSomething()
}
type Resolver struct {
Svc PluginService
}
The executionContext has a resolvers property which is referencing the ResolverRoot interface; Now, In runtime that property is pointing to the Resolver struct instance.
So far so good.
The thing is that I cannot find a way to cast it back (in code) and get access to it and hence its dependencies (services)
I ended up with import cycle not allowed errors or invalid cast errors...
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hey guys, so I'm working with the federation features and I'm stuck when trying to access my dependencies from the populates requires method.
Is this possible?
My populate requires look something like this:
exec/federation.requires.go
resolver/resolver.go
The executionContext has a resolvers property which is referencing the ResolverRoot interface; Now, In runtime that property is pointing to the Resolver struct instance.
So far so good.
The thing is that I cannot find a way to cast it back (in code) and get access to it and hence its dependencies (services)
I ended up with
import cycle not allowed
errors or invalid cast errors...What am I missing?
Regards
Beta Was this translation helpful? Give feedback.
All reactions