@@ -4,6 +4,9 @@ defmodule GraphQL.Type.IntrospectionTest do
44 import ExUnit.TestHelpers
55
66 alias GraphQL.Schema
7+ alias GraphQL.Type.Input
8+ alias GraphQL.Type.Int
9+ alias GraphQL.Type.NonNull
710 alias GraphQL.Type.ObjectType
811 alias GraphQL.Type.String
912
@@ -20,6 +23,71 @@ defmodule GraphQL.Type.IntrospectionTest do
2023 end
2124 end
2225
26+ test "include input types in response to introspection query" do
27+ type = % ObjectType {
28+ name: "Thing" ,
29+ description: "Things" ,
30+ fields: % {
31+ id: % { type: % Int { } } ,
32+ name: % { type: % String { } } ,
33+ } ,
34+ }
35+
36+ thing_input_type = % Input {
37+ name: "ThingInput" ,
38+ fields: % {
39+ name: % { type: % String { } } ,
40+ }
41+ }
42+
43+ output_type = % ObjectType {
44+ name: "SaveThingPayload" ,
45+ fields: % {
46+ thing: % {
47+ type: type ,
48+ resolve: fn ( payload , _ , _ ) ->
49+ payload
50+ end
51+ } ,
52+ } ,
53+ }
54+
55+ input_type = % Input {
56+ name: "SaveThingInput" ,
57+ fields: % {
58+ id: % { type: % NonNull { ofType: % Int { } } } ,
59+ params: % { type: % NonNull { ofType: thing_input_type } } ,
60+ }
61+ }
62+
63+ schema = % Schema {
64+ query: % ObjectType {
65+ name: "QueryRoot" ,
66+ fields: % { onlyField: % { type: % String { } } }
67+ } ,
68+ mutation: % ObjectType {
69+ name: "Mutation" ,
70+ description: "Root object for performing data mutations" ,
71+ fields: % {
72+ save_thing: % {
73+ type: output_type ,
74+ args: % {
75+ input: % {
76+ type: % NonNull { ofType: input_type }
77+ }
78+ } ,
79+ resolve: fn ( data , args , info ) ->
80+ data
81+ end
82+ }
83+ }
84+ }
85+ }
86+
87+ { :ok , result } = execute ( schema , GraphQL.Type.Introspection . query )
88+ assert Enum . find ( result . data [ "__schema" ] [ "types" ] , fn ( type ) -> type [ "name" ] == "ThingInput" end )
89+ end
90+
2391 test "exposes descriptions on types and fields" do
2492 schema = Schema . new ( % {
2593 query: % ObjectType {
0 commit comments