From b8670e1826f05b38e6b2405d0ca916573de43284 Mon Sep 17 00:00:00 2001 From: mo khan Date: Mon, 21 Dec 2020 17:32:32 -0700 Subject: test: play with introspection queries --- test/integration/server_test.rb | 46 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) 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 -- cgit v1.2.3