Skip to content

Commit

Permalink
fix(GraphQL): correct GraphQL variable propagation to custom-dql (#6433)
Browse files Browse the repository at this point in the history
  • Loading branch information
abhimanyusinghgaur authored Sep 14, 2020
1 parent 75bb4db commit afeea49
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 10 additions & 1 deletion graphql/e2e/custom_logic/custom_logic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2748,7 +2748,11 @@ func TestCustomDQL(t *testing.T) {

params = &common.GraphQLParams{
Query: `
query {
query ($count: Int!) {
queryWithVar: getFirstUserByFollowerCount(count: $count) {
screen_name
followers
}
getFirstUserByFollowerCount(count: 10) {
screen_name
followers
Expand All @@ -2764,12 +2768,17 @@ func TestCustomDQL(t *testing.T) {
tweetCount
}
}`,
Variables: map[string]interface{}{"count": 5},
}

result = params.ExecuteAsPost(t, alphaURL)
common.RequireNoGQLErrors(t, result)

require.JSONEq(t, `{
"queryWithVar": {
"screen_name": "abhimanyu",
"followers": 5
},
"getFirstUserByFollowerCount": {
"screen_name": "pawan",
"followers": 10
Expand Down
2 changes: 2 additions & 0 deletions graphql/resolve/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,8 @@ func convertScalarToString(val interface{}) (string, error) {
str = strconv.FormatInt(v, 10)
case float64:
str = strconv.FormatFloat(v, 'f', -1, 64)
case json.Number:
str = v.String()
case nil:
str = ""
default:
Expand Down

0 comments on commit afeea49

Please sign in to comment.