Created
May 31, 2019 01:54
-
-
Save AlecAivazis/166f60fe042f161c0b082c563b293ec9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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