Skip to content

Instantly share code, notes, and snippets.

@sogko
Last active August 3, 2016 07:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sogko/375b413012a3530af25b to your computer and use it in GitHub Desktop.
Save sogko/375b413012a3530af25b to your computer and use it in GitHub Desktop.
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