21 Star 69 Fork 19

gqlengine / GQLEngine

Create your Gitee Account
Explore and code with more than 8 million developers,Free private repositories !:)
Sign up
Clone or Download
contribute
Sync branch
Cancel
Notice: Creating folder will generate an empty file .keep, because not support in Git
Loading...
README.md

GQLEngine is the best productive solution for implementing a graphql server for highest formance

examples

Getting started

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

Features

  • Basic features
    • Object type reflection
    • Interface pre-register
    • Union pre-register
    • Enum reflection
    • Scalar reflection
    • Input reflection
    • Arguments reflection
  • Subscription (Integerates Websocket)
  • Multipart Upload (Upload images/files in graphql query)
  • Custom ID
  • Tracing extensions
  • document tags
  • operation hijacking

About

高性能、功能完备的GraphQL Go语言版本服务端框架 expand collapse
Go
Apache-2.0
Cancel

Releases

No release

GQLEngine

Contributors

All

Activities

Load More
can not load any more
Go
1
https://gitee.com/gqlengine/gqlengine.git
git@gitee.com:gqlengine/gqlengine.git
gqlengine
gqlengine
GQLEngine
master

Search

10d9f8b4 4838521 8bde8327 4838521