5a6e2ec46f
* WIP: migrating the nameservice module * WIP: migrating the nameservice module from dxns to ethermint * refactor: move the proto package version from `v1` to `v1beta1` for vulcanize modules * refactor: added bond module dependency to nameserivce module * feat: added graphql for bond module * feat: added auction module dependency to nameservice module * refactor: refactored the nameservice module * refactor: add human-readable attributes output to cli nameservice `list` * WIP: add grpc query test cases * fix: fix the sub names authority storing issue * WIP: add the test cases * refactor: removed legacyCodec from nameservice * fix: fix the responses for `authority-expiry` and `records-expiry` commands query result * refactor: sort the imports in app * WIP: add test cases for cli query, tx for nameservice module * feat: add test cases for grpc of nameservice module 1. renamed grpc gateway routes from ethermint to vulcanize * refactor: refactored the test cases for grpc lookup of nameservice * refactor: refactored the test cases for bond module * feat: add node status for gql * feat: add get actions by ids in gql * feat: add lookup authorities,resolve name, lookup name queries to gql * updated readme file
45 lines
1.1 KiB
Go
45 lines
1.1 KiB
Go
package gql
|
|
|
|
import (
|
|
"fmt"
|
|
"github.com/99designs/gqlgen/graphql/handler"
|
|
"github.com/99designs/gqlgen/graphql/playground"
|
|
"github.com/cosmos/cosmos-sdk/client"
|
|
"github.com/ethereum/go-ethereum/log"
|
|
"github.com/spf13/viper"
|
|
"net/http"
|
|
)
|
|
|
|
// Server configures and starts the GQL server.
|
|
func Server(ctx client.Context) {
|
|
if !viper.GetBool("gql-server") {
|
|
return
|
|
}
|
|
logFile := viper.GetString("log-file")
|
|
|
|
port := viper.GetString("gql-port")
|
|
|
|
srv := handler.NewDefaultServer(NewExecutableSchema(Config{Resolvers: &Resolver{
|
|
ctx: ctx,
|
|
logFile: logFile,
|
|
}}))
|
|
|
|
http.Handle("/", playground.Handler("GraphQL playground", "/api"))
|
|
|
|
if viper.GetBool("gql-playground") {
|
|
apiBase := viper.GetString("gql-playground-api-base")
|
|
|
|
http.Handle("/webui", playground.Handler("GraphQL playground", apiBase+"/api"))
|
|
http.Handle("/console", playground.Handler("GraphQL playground", apiBase+"/graphql"))
|
|
}
|
|
|
|
http.Handle("/api", srv)
|
|
http.Handle("/graphql", srv)
|
|
|
|
log.Info("Connect to GraphQL playground", "url", fmt.Sprintf("http://localhost:%s", port))
|
|
err := http.ListenAndServe(":"+port, nil)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
}
|