gqlengine open source and published the first edition

gqlengine is a graphql golang solution (server-side framework) Kaifei De science and technology open source, based on  graphql-Go , but without complicated configuration statements, nor  gopher-graphql / graphql-go  as to write schema and then write the corresponding resolver (two times to write business code), but through the go-reflection, resolved to enter the resolver function, automatic analysis graphql type and create. As the following code:

package main

import (
  "net/http"

  "github.com/gqlengine/gqlengine"
)


type MyInfo struct {
  gqlengine.IsGraphQLObject `gqlDesc:"my info"`
  SaySomething string
}

func MySimpleQuery() error {
  panic("not implemented")
}

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)
  }
}

The actual need only engine.NewQuery (MySimpleQuery) can, gqlengine func automatically finds the parameters and the parameters of the deduced corresponding graphql type, such as a return MySimpleQuery MyInfo type, MyInfo structure in this type of marker is GraphQL Object, gqlengine in the Init () is automatically created in the Object.

GQLEngine now supports all types of GraphQL type of reflection, but also has the following powerful features:

  • Websocket Subscription Support (inherited Websocket, users do not need to configure)
  • Multipart Upload (supported by graphql upload any number of photos, documents, etc.)
  • Tracing extensions (support for call hierarchy graphql / link tracking, combined with playground support graphical form observation)

Guess you like

Origin www.oschina.net/news/113222/gqlengine-1-0-released