File tree Expand file tree Collapse file tree 3 files changed +146
-5
lines changed Expand file tree Collapse file tree 3 files changed +146
-5
lines changed Original file line number Diff line number Diff line change @@ -101,6 +101,17 @@ public static function register() {
101101 ),
102102 )
103103 );
104+
105+ register_graphql_enum_type (
106+ 'TaxRateIdTypeEnum ' ,
107+ array (
108+ 'description ' => __ ( 'The Type of Identifier used to fetch a single Tax rate. Default is ID. ' , 'wp-graphql ' ),
109+ 'values ' => array (
110+ 'id ' => self ::get_value ( 'id ' ),
111+ 'database_id ' => self ::get_value ( 'database_id ' ),
112+ ),
113+ )
114+ );
104115 }
105116
106117 /**
Original file line number Diff line number Diff line change @@ -119,11 +119,7 @@ public static function register() {
119119 'type ' => 'Coupon ' ,
120120 'description ' => __ ( 'A coupon object ' , 'wp-graphql-woocommerce ' ),
121121 'args ' => array (
122- 'id ' => array (
123- 'type ' => array (
124- 'non_null ' => 'ID ' ,
125- ),
126- ),
122+ 'id ' => array ( 'type ' => array ( 'non_null ' => 'ID ' ) ),
127123 'idType ' => array (
128124 'type ' => 'CouponIdTypeEnum ' ,
129125 'description ' => __ ( 'Type of ID being used identify coupon ' , 'wp-graphql-woocommerce ' ),
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ class IntrospectionQueryTest extends \Codeception \TestCase \WPTestCase
4+ {
5+
6+ public function setUp () {
7+ // before
8+ parent ::setUp ();
9+
10+ // your set up methods here
11+ }
12+
13+ public function tearDown () {
14+ // your tear down methods here
15+
16+ // then
17+ parent ::tearDown ();
18+ }
19+
20+ // Validate schema.
21+ public function testSchema () {
22+ try {
23+ $ request = new \WPGraphQL \Request ();
24+ $ request ->schema ->assertValid ();
25+
26+ // Assert true upon success.
27+ $ this ->assertTrue ( true );
28+ } catch (\GraphQL \Error \InvariantViolation $ e ) {
29+ // use --debug flag to view.
30+ codecept_debug ( $ e ->getMessage () );
31+
32+ // Fail upon throwing
33+ $ this ->assertTrue ( false );
34+ }
35+ }
36+
37+ // Test introspection query.
38+ public function testIntrospectionQuery () {
39+ $ query = '
40+ query IntrospectionQuery {
41+ __schema {
42+ queryType { name }
43+ mutationType { name }
44+ subscriptionType { name }
45+ types {
46+ ...FullType
47+ }
48+ directives {
49+ name
50+ description
51+ locations
52+ args {
53+ ...InputValue
54+ }
55+ }
56+ }
57+ }
58+ fragment FullType on __Type {
59+ kind
60+ name
61+ description
62+ fields(includeDeprecated: true) {
63+ name
64+ description
65+ args {
66+ ...InputValue
67+ }
68+ type {
69+ ...TypeRef
70+ }
71+ isDeprecated
72+ deprecationReason
73+ }
74+ inputFields {
75+ ...InputValue
76+ }
77+ interfaces {
78+ ...TypeRef
79+ }
80+ enumValues(includeDeprecated: true) {
81+ name
82+ description
83+ isDeprecated
84+ deprecationReason
85+ }
86+ possibleTypes {
87+ ...TypeRef
88+ }
89+ }
90+ fragment InputValue on __InputValue {
91+ name
92+ description
93+ type { ...TypeRef }
94+ defaultValue
95+ }
96+ fragment TypeRef on __Type {
97+ kind
98+ name
99+ ofType {
100+ kind
101+ name
102+ ofType {
103+ kind
104+ name
105+ ofType {
106+ kind
107+ name
108+ ofType {
109+ kind
110+ name
111+ ofType {
112+ kind
113+ name
114+ ofType {
115+ kind
116+ name
117+ ofType {
118+ kind
119+ name
120+ }
121+ }
122+ }
123+ }
124+ }
125+ }
126+ }
127+ }
128+ ' ;
129+
130+ $ results = graphql ( array ( 'query ' => $ query ) );
131+
132+ $ this ->assertArrayNotHasKey ('errors ' , $ results );
133+ }
134+ }
You can’t perform that action at this time.
0 commit comments