diff --git a/gql.go b/gql.go index e7da315..f05409c 100644 --- a/gql.go +++ b/gql.go @@ -15,7 +15,6 @@ package gql import ( "crypto/tls" "fmt" - "net" "net/http" "os" "strconv" @@ -77,15 +76,15 @@ func setCacheEnabled() bool { } func NewConnection() *GraphQL { - return &GraphQL{ + g := GraphQL{ Endpoint: pickGraphqlEndpoint(), HttpClient: &http.Client{ Transport: &http2.Transport{ DisableCompression: false, AllowHTTP: true, - PingTimeout: 5 * time.Second, - DialTLS: func(network, addr string, cfg *tls.Config) (net.Conn, error) { - return net.Dial(network, addr) + PingTimeout: 10 * time.Second, + TLSClientConfig: &tls.Config{ + InsecureSkipVerify: true, }, }, }, @@ -93,6 +92,7 @@ func NewConnection() *GraphQL { Cache: setCacheEnabled(), CacheStore: setupCache(), } + return &g } func setupCache() *bigcache.BigCache { diff --git a/query_test.go b/query_test.go index ae3ca6c..67eb628 100644 --- a/query_test.go +++ b/query_test.go @@ -132,6 +132,25 @@ func (suite *TestSuite) Test_GraphQL_Query() { wantResult: ``, wantErr: true, }, + { + name: "Valid query to https endpoint", + endpoint: "https://web-dev.telegram-bot.app/v1/graphql", + isLocal: false, + args: args{ + queryContent: `query packages_prices { + available_packages: tbl_available_packages(where: {enabled: {_eq: true}}) { + package_name + package_discount + package_price + package_size + package_type + } + }`, + queryVariables: nil, + }, + wantResult: `{"available_packages":[{"package_discount":0,"package_name":"media_1000","package_price":750,"package_size":1000,"package_type":"media"},{"package_discount":5,"package_name":"media_5000","package_price":3563,"package_size":5000,"package_type":"media"},{"package_discount":10,"package_name":"media_10000","package_price":6750,"package_size":10000,"package_type":"media"},{"package_discount":15,"package_name":"media_25000","package_price":15938,"package_size":25000,"package_type":"media"},{"package_discount":0,"package_name":"voice_500","package_price":1000,"package_size":500,"package_type":"voice"},{"package_discount":10,"package_name":"voice_1000","package_price":1800,"package_size":1000,"package_type":"voice"},{"package_discount":15,"package_name":"voice_2500","package_price":4250,"package_size":2500,"package_type":"voice"}]}`, + wantErr: false, + }, } for _, tt := range tests { suite.T().Run(tt.name, func(t *testing.T) {