Skip to content

Commit

Permalink
Merge pull request #491 from adamkasztenny/master
Browse files Browse the repository at this point in the history
Add query with variable test
  • Loading branch information
chris-ramon committed Feb 5, 2020
2 parents 2232917 + 131804e commit d3a54d4
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 d3a54d4

Please sign in to comment.