Commit b8670e1
Changed files (1)
test
integration
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