This repository was archived by the owner on Mar 29, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +103
-0
lines changed
Expand file tree Collapse file tree 1 file changed +103
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Nuwave \Relay \Tests ;
4+
5+ class IntrospectionTest extends BaseTest
6+ {
7+ /**
8+ * @test
9+ */
10+ public function itAcceptsIntrospectionRequestForNodeInterface ()
11+ {
12+ $ query = '{
13+ __type(name: "Node") {
14+ name
15+ kind
16+ fields {
17+ name
18+ type {
19+ kind
20+ ofType {
21+ name
22+ kind
23+ }
24+ }
25+ }
26+ }
27+ } ' ;
28+ $ expected = [
29+ '__type ' => [
30+ 'name ' => 'Node ' ,
31+ 'kind ' => 'INTERFACE ' ,
32+ 'fields ' => [[
33+ 'name ' => 'id ' ,
34+ 'type ' => [
35+ 'kind ' => 'NON_NULL ' ,
36+ 'ofType ' => [
37+ 'name ' => 'ID ' ,
38+ 'kind ' => 'SCALAR '
39+ ]
40+ ]
41+ ]]
42+ ]
43+ ];
44+
45+ $ response = $ this ->graphqlResponse ($ query );
46+
47+ $ this ->assertEquals ($ expected , $ response ['data ' ]);
48+ }
49+
50+ /**
51+ * @test
52+ */
53+ public function itAcceptsIntrospectionRequestForNodeQuery ()
54+ {
55+ $ query = '{
56+ __schema {
57+ queryType {
58+ fields {
59+ name
60+ type {
61+ name
62+ kind
63+ }
64+ args {
65+ name
66+ type {
67+ kind
68+ ofType {
69+ name
70+ kind
71+ }
72+ }
73+ }
74+ }
75+ }
76+ }
77+ } ' ;
78+ $ response = $ this ->graphqlResponse ($ query );
79+ $ fields = array_get ($ response , 'data.__schema.queryType.fields ' );
80+
81+ $ nodeField = array_first ($ fields , function ($ key , $ value ) {
82+ return $ value ['name ' ] == 'node ' ;
83+ });
84+
85+ $ this ->assertEquals ([
86+ 'name ' => 'node ' ,
87+ 'type ' => [
88+ 'name ' => 'Node ' ,
89+ 'kind ' => 'INTERFACE '
90+ ],
91+ 'args ' => [[
92+ 'name ' => 'id ' ,
93+ 'type ' => [
94+ 'kind ' => 'NON_NULL ' ,
95+ 'ofType ' => [
96+ 'name ' => 'ID ' ,
97+ 'kind ' => 'SCALAR '
98+ ]
99+ ]
100+ ]]
101+ ], $ nodeField );
102+ }
103+ }
You can’t perform that action at this time.
0 commit comments