Compare commits

...
3 Commits
3 changed files with 13 additions and 1 deletions
+1 -1
View File
@@ -34,7 +34,7 @@ Therefore, I present you the simple client to which you can copy & paste your gr
* `GRAPHQL_ENDPOINT` - Your GraphQL endpoint. Default: `http://127.0.0.1:9090/v1/graphql`
* `GRAPHQL_CACHE_ENABLED` - Should the query cache be enabled? Default: `false`
* `GRAPHQL_CACHE_TTL` - Cache TTL in seconds for SELECT type of queries. Default: `5`
* `GRAPHQL_OUTPUT` - Output format. Default: `byte`, available: `byte`, `string`
* `GRAPHQL_OUTPUT` - Output format. Default: `string`, available: `byte`, `string`, `mapstring`
* `LOG_LEVEL` - Logging level. Default: `info` available: `debug`, `info`, `warn`, `error`
* `GRAPHQL_RETRIES_ENABLE` - Should retries be enabled? Default: `true`
* `GRAPHQL_RETRIES_NUMBER` - Number of retries: Default: `1`
+4
View File
@@ -98,3 +98,7 @@ func NewConnection() *BaseClient {
func (b *BaseClient) SetEndpoint(endpoint string) {
b.endpoint = endpoint
}
func (b *BaseClient) SetOutput(output string) {
b.responseType = output
}
+8
View File
@@ -120,6 +120,14 @@ func (c *BaseClient) Query(queryContent string, queryVariables interface{}, quer
func (c *BaseClient) decodeResponse(jsonData []byte) any {
switch c.responseType {
case "mapstring":
var response map[string]interface{}
err := json.Unmarshal(jsonData, &response)
if err != nil {
c.Logger.Error(c, "Error while converting to map[string]interface{};", "error", err.Error())
return nil
}
return response
case "string":
return helpers.BytesToString(jsonData)
case "byte":