This commit is contained in:
callebtc
2022-08-31 14:09:17 +02:00
parent ef375c01bd
commit edc4152faf
13 changed files with 335 additions and 124 deletions

View File

@@ -4,32 +4,11 @@ import (
"context"
"time"
"github.com/callebtc/electronwall/config"
"github.com/machinebox/graphql"
log "github.com/sirupsen/logrus"
)
type AutoGenerated struct {
Data struct {
GetNode struct {
GraphInfo struct {
Node struct {
Alias string `json:"alias"`
} `json:"node"`
} `json:"graph_info"`
} `json:"getNode"`
} `json:"data"`
}
var simple_query = `query Node($pubkey: String!) {
getNode(pubkey: $pubkey) {
graph_info {
node {
alias
}
}
}
}`
type Amboss_NodeInfoResponse struct {
Socials struct {
Info struct {
@@ -178,7 +157,10 @@ func (c *AmbossClient) GetNodeInfo(pubkey string) (Amboss_NodeInfoResponse, erro
graphqlRequest.Header.Set("Content-Type", "application/json")
var r_nested Amboss_NodeInfoResponse_Nested
if err := graphqlClient.Run(context.Background(), graphqlRequest, &r_nested.Data); err != nil {
ctx, cancel := context.WithTimeout(context.Background(), time.Second*time.Duration(config.Configuration.ApiRules.Amboss.Timeout))
defer cancel()
if err := graphqlClient.Run(ctx, graphqlRequest, &r_nested.Data); err != nil {
log.Errorf("[amboss] api error: %v", err)
}