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

MutationFn, IDFetcherFn signature to follow conventions #24

Closed bsr203 closed 7 years ago

bsr203 commented 8 years ago

Hi,

MutationFn has the following signature.

Edit: same with IDFetcherFn

type MutationFn func(inputMap map[string]interface{}, info graphql.ResolveInfo, ctx context.Context) (map[string]interface{}, error) it is a convention to have context.Context as the first parameter in functions. So, the signature should be

type MutationFn func(ctx context.Context, inputMap map[string]interface{}, info graphql.ResolveInfo) (map[string]interface{}, error) ref: https://godoc.org/golang.org/x/net/context

Do not store Contexts inside a struct type; instead, pass a Context explicitly to each function that needs it. _The Context should be the first parameter, typically named ctx _:

func DoSomething(ctx context.Context, arg Arg) error {
    // ... use ctx ...
}