summaryrefslogtreecommitdiff
path: root/test/integration
diff options
context:
space:
mode:
authormo khan <mo.khan@gmail.com>2020-12-21 17:32:32 -0700
committermo khan <mo.khan@gmail.com>2020-12-21 17:32:32 -0700
commitb8670e1826f05b38e6b2405d0ca916573de43284 (patch)
tree06da06351b272ed4f7a34883a6678a380d6790cb /test/integration
parentbcc2ad30081dbb78983c1545c188cefa20486a04 (diff)
test: play with introspection queries
Diffstat (limited to 'test/integration')
-rw-r--r--test/integration/server_test.rb46
1 files changed, 46 insertions, 0 deletions
diff --git a/test/integration/server_test.rb b/test/integration/server_test.rb
index ae2da22..9e67241 100644
--- a/test/integration/server_test.rb
+++ b/test/integration/server_test.rb
@@ -60,4 +60,50 @@ class ServerTest < Minitest::Test
json = JSON.parse(last_response.body)
assert 'Query', json['data']['__schema']['queryType']['name']
end
+
+ def test_get_cakes_type
+ header 'Content-Type', 'application/graphql'
+ post '/', <<~GQL
+ {
+ __type(name: "Cake") {
+ name
+ kind
+ }
+ }
+ GQL
+
+ assert last_response.ok?
+ json = JSON.parse(last_response.body)
+ assert_equal 'Cake', json['data']['__type']['name']
+ assert_equal 'OBJECT', json['data']['__type']['kind']
+ end
+
+ def test_get_cake_fields
+ header 'Content-Type', 'application/graphql'
+ post '/', <<~GQL
+ {
+ __type(name: "Cake") {
+ name
+ fields {
+ name
+ type {
+ name
+ kind
+ }
+ }
+ }
+ }
+ GQL
+
+ assert last_response.ok?
+ json = JSON.parse(last_response.body)
+ assert_equal 'Cake', json.dig('data', '__type', 'name')
+ assert_equal [{
+ 'name' => 'name',
+ 'type' => {
+ 'name' => nil,
+ 'kind' => 'NON_NULL'
+ }
+ }], json.dig('data', '__type', 'fields')
+ end
end