Skip to content

Commit

Permalink
refactor: Use int32 for proper gql scalar Int parsing (#1493)
Browse files Browse the repository at this point in the history
Updates the graphql-go lib to
[this](sourcenetwork/graphql-go@fe70855)
update, which applies proper scalar Int parsing and coercing to return
`int32` instead of `int`.

This has *minor* downstream changes as you can see in this PR. Also had
to update the explain tests @shahzadlone since it was using the filter
types directly in the explain output which has now changed to `int32`
  • Loading branch information
jsimnz authored May 11, 2023
1 parent 44503e7 commit 8fca23a
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 28 deletions.
2 changes: 1 addition & 1 deletion connor/eq.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func eq(condition, data any) (bool, error) {
return false, nil
case int64:
return numbers.Equal(cn, data), nil
case int:
case int32:
return numbers.Equal(cn, data), nil
case float64:
return numbers.Equal(cn, data), nil
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,6 @@ require (

// SourceNetwork fork og graphql-go
replace (
github.com/graphql-go/graphql => github.com/sourcenetwork/graphql-go v0.7.10-0.20230427183824-8343db738835
github.com/graphql-go/graphql => github.com/sourcenetwork/graphql-go v0.7.10-0.20230511091704-fe7085512c23
github.com/textileio/go-libp2p-pubsub-rpc => github.com/sourcenetwork/go-libp2p-pubsub-rpc v0.0.0-20230209220544-e16d5e34c4fc
)
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1214,8 +1214,8 @@ github.com/sourcegraph/annotate v0.0.0-20160123013949-f4cad6c6324d/go.mod h1:Udh
github.com/sourcegraph/syntaxhighlight v0.0.0-20170531221838-bd320f5d308e/go.mod h1:HuIsMU8RRBOtsCgI77wP899iHVBQpCmg4ErYMZB+2IA=
github.com/sourcenetwork/go-libp2p-pubsub-rpc v0.0.0-20230209220544-e16d5e34c4fc h1:ZrkklfmN27eENGFmzblEcs35PJ02hmlNgMHE8XJqFAo=
github.com/sourcenetwork/go-libp2p-pubsub-rpc v0.0.0-20230209220544-e16d5e34c4fc/go.mod h1:3rOV6TxePSwADKpnwXBKpTjAA4QyjZBus13xc6VCtSw=
github.com/sourcenetwork/graphql-go v0.7.10-0.20230427183824-8343db738835 h1:P/FCdfRdvRWhNR6DPLlMVZBkOUaG7aVxr0e9CNeukW4=
github.com/sourcenetwork/graphql-go v0.7.10-0.20230427183824-8343db738835/go.mod h1:3Ty9EMes+aoxl8xS0CsuCGQZ4JEsOlC5yqQDLOKoBRw=
github.com/sourcenetwork/graphql-go v0.7.10-0.20230511091704-fe7085512c23 h1:QcSWSYlE1alUC0uOO/trppYMLpR8OuFIL8IqR+PR5sA=
github.com/sourcenetwork/graphql-go v0.7.10-0.20230511091704-fe7085512c23/go.mod h1:3Ty9EMes+aoxl8xS0CsuCGQZ4JEsOlC5yqQDLOKoBRw=
github.com/sourcenetwork/immutable v0.2.2 h1:Qjz1cCWhgjS6YkUTWb53R22wSYMEZhzBghhEzWaFi8c=
github.com/sourcenetwork/immutable v0.2.2/go.mod h1:4jpxObkIQw8pvlIRm4ndZqf3pH9ZjYEw/UYI6GZDJww=
github.com/spacemonkeygo/openssl v0.0.0-20181017203307-c2dcc5cca94a/go.mod h1:7AyxJNCJ7SBZ1MfVQCWD6Uqo2oubI2Eq2y2eqf+A5r0=
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/explain/default/delete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ func TestDefaultExplainMutationRequestWithDeleteUsingFilterAndIds(t *testing.T)
"_and": []any{
dataMap{
"age": dataMap{
"_lt": int(26),
"_lt": int32(26),
},
},
dataMap{
Expand All @@ -409,7 +409,7 @@ func TestDefaultExplainMutationRequestWithDeleteUsingFilterAndIds(t *testing.T)
"_and": []any{
dataMap{
"age": dataMap{
"_lt": int(26),
"_lt": int32(26),
},
},
dataMap{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ func TestExplainQuerySimpleWithDockeysAndFilter(t *testing.T) {
"collectionName": "Author",
"filter": dataMap{
"age": dataMap{
"_eq": int(20),
"_eq": int32(20),
},
},
"spans": []dataMap{
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/explain/default/group_with_filter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func TestExplainGroupByWithFilterOnParent(t *testing.T) {
"collectionName": "Author",
"filter": dataMap{
"age": dataMap{
"_gt": int(63),
"_gt": int32(63),
},
},
"spans": []dataMap{
Expand Down Expand Up @@ -144,7 +144,7 @@ func TestExplainGroupByWithFilterOnInnerGroupSelection(t *testing.T) {
"orderBy": nil,
"filter": dataMap{
"age": dataMap{
"_gt": int(63),
"_gt": int32(63),
},
},
},
Expand Down
6 changes: 3 additions & 3 deletions tests/integration/explain/default/top_with_average_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ func TestDefaultExplainTopLevelAverageRequestWithFilter(t *testing.T) {
"collectionName": "Author",
"filter": dataMap{
"age": dataMap{
"_gt": int(26),
"_gt": int32(26),
"_ne": nil,
},
},
Expand All @@ -206,7 +206,7 @@ func TestDefaultExplainTopLevelAverageRequestWithFilter(t *testing.T) {
"fieldName": "Author",
"filter": dataMap{
"age": dataMap{
"_gt": int(26),
"_gt": int32(26),
"_ne": nil,
},
},
Expand All @@ -223,7 +223,7 @@ func TestDefaultExplainTopLevelAverageRequestWithFilter(t *testing.T) {
"fieldName": "Author",
"filter": dataMap{
"age": dataMap{
"_gt": int(26),
"_gt": int32(26),
"_ne": nil,
},
},
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/explain/default/top_with_count_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func TestDefaultExplainTopLevelCountRequestWithFilter(t *testing.T) {
"collectionName": "Author",
"filter": dataMap{
"age": dataMap{
"_gt": int(26),
"_gt": int32(26),
},
},
"spans": []dataMap{
Expand All @@ -163,7 +163,7 @@ func TestDefaultExplainTopLevelCountRequestWithFilter(t *testing.T) {
"fieldName": "Author",
"filter": dataMap{
"age": dataMap{
"_gt": int(26),
"_gt": int32(26),
},
},
},
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/explain/default/top_with_sum_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ func TestDefaultExplainTopLevelSumRequestWithFilter(t *testing.T) {
"collectionName": "Author",
"filter": dataMap{
"age": dataMap{
"_gt": int(26),
"_gt": int32(26),
},
},
"spans": []dataMap{
Expand All @@ -170,7 +170,7 @@ func TestDefaultExplainTopLevelSumRequestWithFilter(t *testing.T) {
"childFieldName": "age",
"filter": dataMap{
"age": dataMap{
"_gt": int(26),
"_gt": int32(26),
},
},
},
Expand Down
6 changes: 3 additions & 3 deletions tests/integration/explain/default/with_average_join_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ func TestDefaultExplainRequestWithAverageOnMultipleJoinedFieldsWithFilter(t *tes
"fieldName": "articles",
"filter": dataMap{
"pages": dataMap{
"_gt": int(3),
"_gt": int32(3),
"_ne": nil,
},
},
Expand All @@ -337,7 +337,7 @@ func TestDefaultExplainRequestWithAverageOnMultipleJoinedFieldsWithFilter(t *tes
"fieldName": "articles",
"filter": dataMap{
"pages": dataMap{
"_gt": int(3),
"_gt": int32(3),
"_ne": nil,
},
},
Expand Down Expand Up @@ -426,7 +426,7 @@ func TestDefaultExplainRequestWithAverageOnMultipleJoinedFieldsWithFilter(t *tes
"collectionName": "Article",
"filter": dataMap{
"pages": dataMap{
"_gt": int(3),
"_gt": int32(3),
"_ne": nil,
},
},
Expand Down
18 changes: 9 additions & 9 deletions tests/integration/explain/default/with_filter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func TestDefaultExplainRequestWithIntegerEqualFilter(t *testing.T) {
"collectionName": "Author",
"filter": dataMap{
"age": dataMap{
"_eq": int(26),
"_eq": int32(26),
},
},
"spans": []dataMap{
Expand Down Expand Up @@ -170,7 +170,7 @@ func TestDefaultExplainRequestWithGreaterThanFilter(t *testing.T) {
"collectionName": "Author",
"filter": dataMap{
"age": dataMap{
"_gt": int(20),
"_gt": int32(20),
},
},
"spans": []dataMap{
Expand Down Expand Up @@ -233,12 +233,12 @@ func TestDefaultExplainRequestWithLogicalCompoundAndFilter(t *testing.T) {
"_and": []any{
dataMap{
"age": dataMap{
"_gt": int(20),
"_gt": int32(20),
},
},
dataMap{
"age": dataMap{
"_lt": int(50),
"_lt": int32(50),
},
},
},
Expand Down Expand Up @@ -303,12 +303,12 @@ func TestDefaultExplainRequestWithLogicalCompoundOrFilter(t *testing.T) {
"_or": []any{
dataMap{
"age": dataMap{
"_eq": int(55),
"_eq": int32(55),
},
},
dataMap{
"age": dataMap{
"_eq": int(19),
"_eq": int32(19),
},
},
},
Expand Down Expand Up @@ -372,9 +372,9 @@ func TestDefaultExplainRequestWithMatchInsideList(t *testing.T) {
"filter": dataMap{
"age": dataMap{
"_in": []any{
int(19),
int(40),
int(55),
int32(19),
int32(40),
int32(55),
},
},
},
Expand Down

0 comments on commit 8fca23a

Please sign in to comment.