Skip to content

Instantly share code, notes, and snippets.

@AlecAivazis
Created May 31, 2019 01:54
Show Gist options
  • Save AlecAivazis/166f60fe042f161c0b082c563b293ec9 to your computer and use it in GitHub Desktop.
Save AlecAivazis/166f60fe042f161c0b082c563b293ec9 to your computer and use it in GitHub Desktop.
import "github.com/vektah/gqlparser/ast"
var viewerField = &gateway.QueryField{
Name: "viewer",
Type: ast.NamedType("User", &ast.Position{}),
// this function must return the ID of the object that the field resolves to
Resolver: func(ctx context.Context, args map[string]interface{}) (string, error) {
// for now just return the value in context
return ctx.Value("user-id").(string), nil
},
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment