mirror of
https://github.com/lukaszraczylo/go-simple-graphql.git
synced 2026-10-14 00:58:32 +00:00
Minor bugfixes, use semver-gen.
This commit is contained in:
@@ -3,9 +3,11 @@ module github.com/lukaszraczylo/simple-gql-client
|
||||
go 1.16
|
||||
|
||||
require (
|
||||
github.com/andybalholm/brotli v1.0.2 // indirect
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/klauspost/compress v1.12.2 // indirect
|
||||
github.com/stretchr/testify v1.7.0
|
||||
github.com/tidwall/gjson v1.7.3
|
||||
github.com/valyala/fasthttp v1.22.0
|
||||
github.com/tidwall/gjson v1.7.5
|
||||
github.com/valyala/fasthttp v1.24.0
|
||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
|
||||
)
|
||||
|
||||
@@ -1,25 +1,28 @@
|
||||
github.com/andybalholm/brotli v1.0.1 h1:KqhlKozYbRtJvsPrrEeXcO+N2l6NYT5A2QAFmSULpEc=
|
||||
github.com/andybalholm/brotli v1.0.1/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu3qAvBg8x/Y=
|
||||
github.com/andybalholm/brotli v1.0.2 h1:JKnhI/XQ75uFBTiuzXpzFrUriDPiZjlOSzh6wXogP0E=
|
||||
github.com/andybalholm/brotli v1.0.2/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu3qAvBg8x/Y=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/klauspost/compress v1.11.8 h1:difgzQsp5mdAz9v8lm3P/I+EpDKMU/6uTMw1y1FObuo=
|
||||
github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||
github.com/klauspost/compress v1.11.8/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs=
|
||||
github.com/klauspost/compress v1.12.2 h1:2KCfW3I9M7nSc5wOqXAlW2v2U6v+w6cbjvbfp+OykW8=
|
||||
github.com/klauspost/compress v1.12.2/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/tidwall/gjson v1.7.3 h1:9dOulDrkCJf1mwljVMhXNQr9ZL2NvajRX7A1R8c6Qxw=
|
||||
github.com/tidwall/gjson v1.7.3/go.mod h1:5/xDoumyyDNerp2U36lyolv46b3uF/9Bu6OfyQ9GImk=
|
||||
github.com/tidwall/gjson v1.7.5 h1:zmAN/xmX7OtpAkv4Ovfso60r/BiCi5IErCDYGNJu+uc=
|
||||
github.com/tidwall/gjson v1.7.5/go.mod h1:5/xDoumyyDNerp2U36lyolv46b3uF/9Bu6OfyQ9GImk=
|
||||
github.com/tidwall/match v1.0.3 h1:FQUVvBImDutD8wJLN6c5eMzWtjgONK9MwIBCOrUJKeE=
|
||||
github.com/tidwall/match v1.0.3/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
|
||||
github.com/tidwall/pretty v1.1.0 h1:K3hMW5epkdAVwibsQEfR/7Zj0Qgt4DxtNumTq/VloO8=
|
||||
github.com/tidwall/pretty v1.1.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
|
||||
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
|
||||
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
|
||||
github.com/valyala/fasthttp v1.22.0 h1:OpwH5KDOJ9cS2bq8fD+KfT4IrksK0llvkHf4MZx42jQ=
|
||||
github.com/valyala/fasthttp v1.22.0/go.mod h1:0mw2RjXGOzxf4NL2jni3gUQ7LfjjUSiG5sskOUUSEpU=
|
||||
github.com/valyala/fasthttp v1.24.0 h1:AAiG4oLDUArTb7rYf9oO2bkGooOqCaUF6a2u8asBP3I=
|
||||
github.com/valyala/fasthttp v1.24.0/go.mod h1:0mw2RjXGOzxf4NL2jni3gUQ7LfjjUSiG5sskOUUSEpU=
|
||||
github.com/valyala/tcplisten v0.0.0-20161114210144-ceec8f93295a/go.mod h1:v3UYOV9WzVtRmSR+PDvWpU/qWl4Wa5LApYYX4ZtKbio=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
|
||||
|
||||
@@ -68,9 +68,9 @@ func Query(query string, variables interface{}, headers map[string]interface{})
|
||||
defer fasthttp.ReleaseRequest(req)
|
||||
req.Header.SetContentType("application/json")
|
||||
for header, value := range headers {
|
||||
req.Header.Set(fmt.Sprintf("%v", header), fmt.Sprintf("%v", value))
|
||||
req.Header.Add(fmt.Sprintf("%v", header), fmt.Sprintf("%v", value))
|
||||
}
|
||||
req.Header.SetMethodBytes([]byte("POST"))
|
||||
req.Header.SetMethod("POST")
|
||||
req.SetBody(readyQuery)
|
||||
req.SetRequestURI(GraphQLUrl)
|
||||
res := fasthttp.AcquireResponse()
|
||||
|
||||
+10
-4
@@ -29,13 +29,13 @@ func Test_queryBuilder(t *testing.T) {
|
||||
{
|
||||
name: "Advanced query",
|
||||
args: args{
|
||||
data: `query checkifUserIsAdmin($UserID: bigint, $GroupID: bigint) { tbl_user_group_admins(where: {is_admin: {_eq: "1"}, user_id: {_eq: $UserID}, group_id: {_eq: $GroupID}}) { id is_admin } }`,
|
||||
data: `query checkifUserIsAdmin($UserID: bigint, $GroupID: bigint) { tbl_user_group_admins(where: {is_admin: {_eq: true}, user_id: {_eq: $UserID}, group_id: {_eq: $GroupID}}) { id is_admin } }`,
|
||||
variables: map[string]interface{}{
|
||||
"UserID": 37,
|
||||
"GroupID": 11007,
|
||||
},
|
||||
},
|
||||
want: `{"query":"query checkifUserIsAdmin($UserID: bigint, $GroupID: bigint) { tbl_user_group_admins(where: {is_admin: {_eq: \"1\"}, user_id: {_eq: $UserID}, group_id: {_eq: $GroupID}}) { id is_admin } }","variables":{"GroupID":11007,"UserID":37}}`,
|
||||
want: `{"query":"query checkifUserIsAdmin($UserID: bigint, $GroupID: bigint) { tbl_user_group_admins(where: {is_admin: {_eq: true}, user_id: {_eq: $UserID}, group_id: {_eq: $GroupID}}) { id is_admin } }","variables":{"GroupID":11007,"UserID":37}}`,
|
||||
},
|
||||
}
|
||||
assert := assert.New(t)
|
||||
@@ -57,13 +57,14 @@ func Test_queryAgainstDatabaseExecution(t *testing.T) {
|
||||
headers := map[string]interface{}{
|
||||
"x-hasura-user-id": 37,
|
||||
"x-hasura-user-uuid": "bde3262e-b42e-4151-ac10-d43fb38f44a5",
|
||||
"Authorization": "bearer LaPotatoDiBanani",
|
||||
}
|
||||
variables := map[string]interface{}{
|
||||
"UserID": 37,
|
||||
"GroupID": 11007,
|
||||
}
|
||||
var query = `query checkifUserIsAdmin($UserID: bigint, $GroupID: bigint) {
|
||||
tbl_user_group_admins(where: {is_admin: {_eq: "1"}, user_id: {_eq: $UserID}, group_id: {_eq: $GroupID}}) {
|
||||
tbl_user_group_admins(where: {is_admin: {_eq: true}, user_id: {_eq: $UserID}, group_id: {_eq: $GroupID}}) {
|
||||
id
|
||||
is_admin
|
||||
}
|
||||
@@ -72,7 +73,7 @@ func Test_queryAgainstDatabaseExecution(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Log("Query execution errored. Is GQL server up?")
|
||||
}
|
||||
expected := `{"tbl_user_group_admins":[{"id":109,"is_admin":1}]}`
|
||||
expected := `{"tbl_user_group_admins":[{"id":109,"is_admin":true}]}`
|
||||
assert.Equal(expected, string(result), "Query result execution should be equal")
|
||||
}
|
||||
|
||||
@@ -112,6 +113,11 @@ func Test_initialize(t *testing.T) {
|
||||
env_endpoint: "",
|
||||
expected: "http://127.0.0.1:9090/v1/graphql",
|
||||
},
|
||||
{
|
||||
name: "Setting custom endpoint",
|
||||
env_endpoint: "http://127.0.0.1:8080/v1/graphql",
|
||||
expected: "http://127.0.0.1:8080/v1/graphql",
|
||||
},
|
||||
}
|
||||
assert := assert.New(t)
|
||||
backupEnv, present := os.LookupEnv("GRAPHQL_ENDPOINT")
|
||||
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
version: 1
|
||||
force:
|
||||
major: 1
|
||||
minor: 22
|
||||
patch: 38
|
||||
commit: 4508a46ac5bf8fc5fb264fbb0de58d3b8827ba2d
|
||||
wording:
|
||||
patch:
|
||||
- patch
|
||||
- hotfix
|
||||
- update
|
||||
- initial
|
||||
minor:
|
||||
- change
|
||||
- improve
|
||||
major:
|
||||
- breaking
|
||||
Reference in New Issue
Block a user