func writeArgumentType(w io.Writer, t reflect.Type, value bool) {
	if t.Kind() == reflect.Ptr {
		writeArgumentType(w, t.Elem(), false)
		return
	}
	switch t.Kind() {
	case reflect.Slice, reflect.Array:
		io.WriteString(w, "[")
		writeArgumentType(w, t.Elem(), true)
		io.WriteString(w, "]")
	default:
		name := t.Name()
		realType := utils.GetGraphQLType(t.Kind())
		if name == "string" {  
			name = "ID"
		}
		io.WriteString(w, realType.Name())
	}
	if value {
		io.WriteString(w, "!")
	}
}
writeArgumentType writes a minified GraphQL type for t to w.
value indicates whether t is a value (required) type or pointer (optional) type.
If value is true, then "!" is written at the end of t.
package generate
import (
	"bytes"
	"fmt"
	"github.com/terra-project/mantle-sdk/graph/graph_types"
	"io"
	"reflect"
	"sort"
	"strings"
	"github.com/terra-project/mantle-sdk/utils"
)
func GenerateQuery(v interface{}, variables map[string]interface{}) string {
	query := query(v)
	if len(variables) > 0 {
		return "query(" + queryArguments(variables) + ")" + query
	}
	return query
}
func queryArguments(variables map[string]interface{}) string {
	keys := make([]string, 0, len(variables))
	for k := range variables {
		keys = append(keys, k)
	}
	sort.Strings(keys)
	var buf bytes.Buffer
	for _, k := range keys {
		io.WriteString(&buf, "$")
		io.WriteString(&buf, k)
		io.WriteString(&buf, ":")
		writeArgumentType(&buf, reflect.TypeOf(variables[k]), true)
	}
	return buf.String()
}