graphql-go / relay

A Go/Golang library to help construct a graphql-go server supporting react-relay.
MIT License
424 stars 58 forks source link

Context support #14

Closed bsr203 closed 8 years ago

bsr203 commented 8 years ago

In graphql, Context is passed through ResolveParams. https://github.com/graphql-go/graphql/commit/14c8c6d488e09446c6217b811b266a663ffc8acc

This is not available in relay API. the resolve function for mutation has following signature.

type MutationFn func(inputMap map[string]interface{}, info graphql.ResolveInfo) map[string]interface{}

can we pass ResolveParams or Context directly?

thanks.

chris-ramon commented 8 years ago

Hi @bsr203, thanks for bring this up, I think we should make available Context through Info.Context, meaning a change on graphql-go is required. I think we are just fine moving it to it since it is meant for that purpose.

The resolve function's optional third argument is a collection of information about the current execution state. https://github.com/graphql-go/graphql/blob/master/executor.go#L492-L493

chris-ramon commented 8 years ago

Also as you mentioned above, other good solution would be to pass Context directly to MutationFn, I will submit a PR for that :+1:

bsr203 commented 8 years ago

thanks Chris for quick response and the fix. greatly appreciate all your hard work.

chris-ramon commented 8 years ago

closing this one, resolved with #15 :+1: