-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…6424) Fixes GRAPHQL-642. For this restoreStatus query using variable ``` query restoreStatus($restoreId: Int!) { restoreStatus(restoreId: $restoreId) { status errors } } ``` was giving this panic ``` panic: interface conversion: interface {} is json.Number, not int64. ``` Whereas the expected result should be ``` { "data": { "restoreStatus": { "status": "UNKNOWN", "errors": [] } }, "extensions": {} } ``` This PR fixes this panic, Now `resolveStatus` with or without variable works fine. (cherry picked from commit 45afae9)
- Loading branch information
1 parent
d7feabd
commit 3d2bfe7
Showing
2 changed files
with
57 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package admin | ||
|
||
import ( | ||
"encoding/json" | ||
"strings" | ||
"testing" | ||
|
||
"github.com/dgraph-io/dgraph/graphql/schema" | ||
"github.com/dgraph-io/dgraph/graphql/test" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestRestoreStatus(t *testing.T) { | ||
gqlSchema := test.LoadSchema(t, graphqlAdminSchema) | ||
Query := `query restoreStatus($restoreId: Int!) { | ||
restoreStatus(restoreId: $restoreId) { | ||
status | ||
errors | ||
} | ||
}` | ||
variables := `{"restoreId": 2 }` | ||
vars := make(map[string]interface{}) | ||
d := json.NewDecoder(strings.NewReader(variables)) | ||
d.UseNumber() | ||
err := d.Decode(&vars) | ||
require.NoError(t, err) | ||
|
||
op, err := gqlSchema.Operation( | ||
&schema.Request{ | ||
Query: Query, | ||
Variables: vars, | ||
}) | ||
require.NoError(t, err) | ||
gqlQuery := test.GetQuery(t, op) | ||
v, err := getRestoreStatusInput(gqlQuery) | ||
require.NoError(t, err) | ||
require.IsType(t, int64(2), v, nil) | ||
} |