-
Notifications
You must be signed in to change notification settings - Fork 843
type of ResolveInfo.RootValue should be interface{} #65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi @bsr203 From @pyros2097 comments in #25
I think the main take-away from that PR is that package graphql
// passed into `graphql.Graphql(...)`
type Params struct {
RootObject map[string]interface{}
}
type ExecuteParams struct {
Root interface{}
}
type BuildExecutionCtxParams struct {
Root interface{}
}
// finally available as RootValue in ResolveInfo through GQLFRParams
type ResolveInfo struct {
RootValue interface{}
} Along the way, RootObject gets renamed as Root, and finally RootValue. It would be great to have a consistent name for While I'm leaning towards updating RootObject/RootValue to Changing it Discussion welcomed! |
It does avoid one casting/type assertion though
we know,
otherwise above example could have been
|
Oh yes you are right, I meant to say it does not remove/eliminate all casting, but like you said, it does avoid one casting; sorry, its wayyyy past my bed time here right now lol 😄, Again, I'm all for As @pyros2097 brought up a suggestion previously that RootObject/RootValue could be constantly be made an |
another consideration being it https://godoc.org/golang.org/x/net/context type, as from the original pull request, if any of the deadlines, cancelation signals, useful. I would definitely use it for |
@bsr203 The context type seems good since we are going to be passing a context object usually and most of the other http server libs use it for request handling. But I Think this will make sense only if you use graphql within the http server context. I prefer the rootValue as an interface{} type as we are most probably going to attach all our session data and env variables to a struct and that would become the rootValue. |
@pyros2097 context has nothing to do with http though. These are the only dependencies.
they are used to store per request data and allow cancellation of goroutines elegantly. Also, you could store any value in it ( Edit:@pyros2097 thinking about it it may be ok to be ctx := val.(net.Context) so, you guys decide, but not |
Should RootValue be removed, now that we have Context? Context appears to satisfy most of the use cases of RootValue, EXCEPT for sharing data between resolvers during a request. That is, two resolve functions (possibly executing in parallel) could, in theory, coordinate via RootValue, right? However, the Context is not meaningfully mutable in the current implementation. |
Closing issue due to inactivity. You can find more info on the current |
…rams.Root that is an interface{}
this was discussed by few at #25
this avoid an extra casting
The text was updated successfully, but these errors were encountered: