Fetch the repository succeeded.
Get the module:
go get -u github.com/gqlengine/gqlengine
main.go
package main
import (
"net/http"
"github.com/gqlengine/gqlengine"
)
func main() {
engine := gqlengine.NewEngine(gqlengine.Options{
Tracing: true, // enable tracing extensions
})
// register your queries, mutations and subscriptions
engine.NewQuery(mySimpleQuery)
// do NOT forget init the engine
if err := engine.Init(); err != nil {
panic(err)
}
// serve for HTTP
http.HandleFunc("/api/graphql", engine.ServeHTTP)
if err := http.ListenAndServe(":8000", nil); err != nil {
panic(err)
}
}
api.go
package main
type MyInfo struct {
gqlengine.IsGraphQLObject `gqlDesc:"my info"`
SaySomething string
}
func mySimpleQuery() error {
panic("not implemented")
}
use playground
go get -u github.com/gqlengine/playground
update the code
...
import (
"github.com/gorilla/mux"
"github.com/gqlengine/playground"
)
...
func main() {
... // init your gql engine
playground.SetEndpoints("/api/graphql", "/api/graphql/subscriptions")
// recommends to use 'gorilla/mux' to serve the playground web assets
r := mux.NewRouter()
r.HandleFunc("/api/graphql", engine.ServeHTTP)
r.HandleFunc("/api/graphql/subscriptions", engine.ServeWebsocket)
r.PathPrefix("/api/graphql/playground").
Handler(http.StripPrefix("/api/graphql/playground",
http.FileServer(playground.WebBundle)))
println("open playground http://localhost:9996/api/graphql/playground/")
if err := http.ListenAndServe(":9996", r); err != nil {
panic(err)
}
}
open browser, you can get the playground all in box
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。
Activity
Community
Health
Trend
Influence
:Code submit frequency
:React/respond to issue & PR etc.
:Well-balanced team members and collaboration
:Recent popularity of project
:Star counts, download counts etc.