Skip to content

Commit

Permalink
Add query with variable test
Browse files Browse the repository at this point in the history
  • Loading branch information
adamkasztenny authored Jun 20, 2019
1 parent 199d20b commit 1ce3dcd
Showing 1 changed file with 27 additions and 5 deletions.
32 changes: 27 additions & 5 deletions graphql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ import (
)

type T struct {
Query string
Schema graphql.Schema
Expected interface{}
Query string
Schema graphql.Schema
Expected interface{}
Variables map[string]interface{}
}

var Tests = []T{}
Expand Down Expand Up @@ -69,14 +70,35 @@ func init() {
},
},
},
{
Query: `
query HumanByIdQuery($id: String!) {
human(id: $id) {
name
}
}
`,
Schema: testutil.StarWarsSchema,
Expected: &graphql.Result{
Data: map[string]interface{}{
"human": map[string]interface{}{
"name": "Darth Vader",
},
},
},
Variables: map[string]interface{}{
"id": "1001",
},
},
}
}

func TestQuery(t *testing.T) {
for _, test := range Tests {
params := graphql.Params{
Schema: test.Schema,
RequestString: test.Query,
Schema: test.Schema,
RequestString: test.Query,
VariableValues: test.Variables,
}
testGraphql(test, params, t)
}
Expand Down

0 comments on commit 1ce3dcd

Please sign in to comment.