Skip to content

Instantly share code, notes, and snippets.

@michaljemala
Created April 5, 2019 10:09
Show Gist options
  • Select an option

  • Save michaljemala/c6d2d38652d70b4ed563313f74092876 to your computer and use it in GitHub Desktop.

Select an option

Save michaljemala/c6d2d38652d70b4ed563313f74092876 to your computer and use it in GitHub Desktop.

Revisions

  1. michaljemala created this gist Apr 5, 2019.
    32 changes: 32 additions & 0 deletions graphql_desc.go
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,32 @@
    package main

    import (
    "log"
    "net/http"

    "github.com/graph-gophers/graphql-go"
    "github.com/graph-gophers/graphql-go/relay"
    )

    func main() {
    http.Handle("/query", &relay.Handler{
    Schema: graphql.MustParseSchema(
    `schema {
    query: Query
    }
    " This is a described type. "
    type Query {
    hello: String!
    }
    type NonDescribed {}
    `,
    new(resolver),
    graphql.UseStringDescriptions(),
    ),
    })
    log.Fatal(http.ListenAndServe(":8080", nil))
    }

    type resolver struct{}

    func (*resolver) Hello() string { return "Hello, world!" }