forked from dfuse-io/dfuse-eosio
/
dgraphql.go
63 lines (59 loc) · 3.35 KB
/
dgraphql.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package cli
import (
dgraphqlApp "github.com/dfuse-io/dgraphql/app/dgraphql"
"github.com/invisible-train-40/zsw-lishi-launcher/launcher"
"github.com/spf13/cobra"
"github.com/spf13/viper"
dgraphqlEosio "github.com/zhongshuwen/dfuse-eosio/dgraphql"
)
func init() {
// Dgraphql
launcher.RegisterApp(&launcher.AppDef{
ID: "dgraphql",
Title: "GraphQL",
Description: "Serves GraphQL queries to clients",
MetricsID: "dgraphql",
Logger: launcher.NewLoggingDef("github.com/dfuse-io/dgraphql.*", nil),
RegisterFlags: func(cmd *cobra.Command) error {
cmd.Flags().String("dgraphql-http-addr", DgraphqlHTTPServingAddr, "TCP Listener addr for http")
cmd.Flags().String("dgraphql-grpc-addr", DgraphqlGRPCServingAddr, "TCP Listener addr for gRPC")
cmd.Flags().String("dgraphql-abi-addr", ABICodecServingAddr, "Base URL for abicodec service")
cmd.Flags().Bool("dgraphql-disable-authentication", false, "disable authentication for both grpc and http services")
cmd.Flags().Bool("dgraphql-override-trace-id", false, "flag to override trace id or not")
cmd.Flags().String("dgraphql-protocol", "eos", "name of the protocol")
cmd.Flags().String("dgraphql-auth-url", JWTIssuerURL, "Auth URL used to configure the dfuse js client")
cmd.Flags().String("dgraphql-api-key", DgraphqlAPIKey, "API key used in graphiql")
cmd.Flags().String("dgraphql-tokenmeta-addr", TokenmetaGRPCServingAddr, "Tokenmeta client endpoint url")
cmd.Flags().String("dgraphql-accounthist-account-addr", AccountHistGRPCServingAddr, "Account history account indexed server client endpoint url, empty string disables the operation")
cmd.Flags().String("dgraphql-accounthist-account-contract-addr", "", "Account history account-contract indexed server client endpoint url, empty string disables the operation")
return nil
},
FactoryFunc: func(runtime *launcher.Runtime) (launcher.App, error) {
dfuseDataDir := runtime.AbsDataDir
return dgraphqlEosio.NewApp(&dgraphqlEosio.Config{
// eos specifc configs
SearchAddr: viper.GetString("common-search-addr"),
ABICodecAddr: viper.GetString("dgraphql-abi-addr"),
BlockMetaAddr: viper.GetString("common-blockmeta-addr"),
TokenmetaAddr: viper.GetString("dgraphql-tokenmeta-addr"),
AccountHistAccountAddr: viper.GetString("dgraphql-accounthist-account-addr"),
AccountHistAccountContractAddr: viper.GetString("dgraphql-accounthist-account-contract-addr"),
KVDBDSN: mustReplaceDataDir(dfuseDataDir, viper.GetString("common-trxdb-dsn")),
RatelimiterPlugin: viper.GetString("common-ratelimiter-plugin"),
Config: dgraphqlApp.Config{
// base dgraphql configs
// need to be passed this way because promoted fields
HTTPListenAddr: viper.GetString("dgraphql-http-addr"),
GRPCListenAddr: viper.GetString("dgraphql-grpc-addr"),
AuthPlugin: viper.GetString("common-auth-plugin"),
MeteringPlugin: viper.GetString("common-metering-plugin"),
NetworkID: viper.GetString("common-network-id"),
OverrideTraceID: viper.GetBool("dgraphql-override-trace-id"),
Protocol: viper.GetString("dgraphql-protocol"),
JwtIssuerURL: viper.GetString("dgraphql-auth-url"),
APIKey: viper.GetString("dgraphql-api-key"),
},
})
},
})
}