Created
March 9, 2020 01:16
-
-
Save vniche/93ebbb8ee8e27cab6148038e23779122 to your computer and use it in GitHub Desktop.
Global in-memory storage for GraphQL in Golang
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
... | |
"github.com/artemis-tech/sample-graph/graph" | |
) | |
func main() { | |
port := "3030" | |
if os.Getenv("PORT") != "" { | |
port = os.Getenv("PORT") | |
} | |
// initializes graph package global Users variable with 0 entries and capacity of 30 | |
graph.Users = make([]*graph.User, 0, 30) | |
http.Handle("/graphql/playground", handler.Playground("GraphQL playground", "/query")) | |
... |
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
... | |
type Resolver struct{} | |
// Users stands for the in-memory list of users | |
var Users []*User | |
func (r *mutationResolver) Signup(ctx context.Context, input NewUser) (string, error) { | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment