Last active
August 3, 2016 07:39
-
-
Save sogko/375b413012a3530af25b to your computer and use it in GitHub Desktop.
hello-world-graphql-part-1 - Server
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
package main | |
import ( | |
"net/http" | |
"github.com/graphql-go/graphql" | |
"github.com/graphql-go/graphql-go-handler" | |
) | |
var queryType = graphql.NewObject(graphql.ObjectConfig{ | |
// ... | |
}) | |
var Schema, _ = graphql.NewSchema(graphql.SchemaConfig{ | |
// ... | |
}) | |
func main() { | |
// create a graphl-go HTTP handler with our previously defined schema | |
// and we also set it to return pretty JSON output | |
h := gqlhandler.New(&gqlhandler.Config{ | |
Schema: &Schema, | |
Pretty: true, | |
}) | |
// serve a GraphQL endpoint at `/graphql` | |
http.Handle("/graphql", h) | |
// and serve! | |
http.ListenAndServe(":8080", nil) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment