@@ -56,6 +56,124 @@ public function testIntrospectionQuery()
56
56
$ this ->assertArrayHasKey ('__schema ' , $ this ->graphQlQuery ($ query ));
57
57
}
58
58
59
+ /**
60
+ * Tests that Introspection is allowed by default
61
+ * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
62
+ */
63
+ public function testIntrospectionQueryWithOnlySchema ()
64
+ {
65
+ $ query
66
+ = <<<QUERY
67
+ {
68
+ __schema {
69
+ queryType { name }
70
+ types{
71
+ ...FullType
72
+ }
73
+ }
74
+ }
75
+ fragment FullType on __Type{
76
+ name
77
+ kind
78
+ fields(includeDeprecated:true){
79
+ name
80
+ args{
81
+ ...InputValue
82
+ }
83
+ }
84
+ }
85
+
86
+ fragment TypeRef on __Type {
87
+ kind
88
+ name
89
+ ofType{
90
+ kind
91
+ name
92
+ }
93
+ }
94
+ fragment InputValue on __InputValue {
95
+ name
96
+ description
97
+ type { ...TypeRef }
98
+ defaultValue
99
+ }
100
+ QUERY ;
101
+ $ this ->assertArrayHasKey ('__schema ' , $ this ->graphQlQuery ($ query ));
102
+ $ response = $ this ->graphQlQuery ($ query );
103
+
104
+ $ query
105
+ = <<<QUERY
106
+ query IntrospectionQuery {
107
+ __schema {
108
+ queryType { name }
109
+ types{
110
+ ...FullType
111
+ }
112
+ }
113
+ }
114
+ fragment FullType on __Type{
115
+ name
116
+ kind
117
+ fields(includeDeprecated:true){
118
+ name
119
+ args{
120
+ ...InputValue
121
+ }
122
+ }
123
+ }
124
+
125
+ fragment TypeRef on __Type {
126
+ kind
127
+ name
128
+ ofType{
129
+ kind
130
+ name
131
+ }
132
+ }
133
+ fragment InputValue on __InputValue {
134
+ name
135
+ description
136
+ type { ...TypeRef }
137
+ defaultValue
138
+ }
139
+ QUERY ;
140
+ $ this ->assertArrayHasKey ('__schema ' , $ this ->graphQlQuery ($ query ));
141
+ $ responseFields = $ this ->graphQlQuery ($ query );
142
+ $ this ->assertResponseFields ($ response , $ responseFields );
143
+ $ this ->assertEquals ($ responseFields , $ response );
144
+ }
145
+
146
+ /**
147
+ * Tests that Introspection is allowed by default
148
+ * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
149
+ */
150
+ public function testIntrospectionQueryWithOnlyType ()
151
+ {
152
+ $ query
153
+ = <<<QUERY
154
+ {
155
+ __type(name:"Query")
156
+ {
157
+ name
158
+ kind
159
+ fields(includeDeprecated:true){
160
+ name
161
+ type{
162
+ kind
163
+ name
164
+ }
165
+ description
166
+ isDeprecated
167
+ deprecationReason
168
+ }
169
+ }
170
+ }
171
+ QUERY ;
172
+ $ this ->assertArrayHasKey ('__type ' , $ this ->graphQlQuery ($ query ));
173
+ $ response = $ this ->graphQlQuery ($ query );
174
+ $ this ->assertNotEmpty ($ response ['__type ' ]['fields ' ]);
175
+ }
176
+
59
177
/**
60
178
* Tests that Introspection Query with deprecated annotations on enum values, fields are read.
61
179
*/
0 commit comments