Skip to content

Instantly share code, notes, and snippets.

@sogko sogko/main.go
Last active Aug 3, 2016

Embed
What would you like to do?
hello-world-graphql-part-1 - Server
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
You can’t perform that action at this time.