This repository was archived by the owner on Feb 10, 2019. It is now read-only.
File tree 3 files changed +34
-4
lines changed 3 files changed +34
-4
lines changed Original file line number Diff line number Diff line change @@ -67,7 +67,7 @@ public function schema($schema = null)
67
67
$ this ->typesInstances [$ name ] = $ objectType ;
68
68
$ types [] = $ objectType ;
69
69
70
- $ this ->addType ($ type , $ name );
70
+ $ this ->addType ($ type , is_numeric ( $ name ) ? null : $ name );
71
71
}
72
72
} else {
73
73
foreach ($ this ->types as $ name => $ type ) {
Original file line number Diff line number Diff line change @@ -77,14 +77,21 @@ public function testSchemaWithArray()
77
77
'updateExampleCustom ' => UpdateExampleMutation::class
78
78
],
79
79
'types ' => [
80
- CustomExampleType::class
80
+ CustomExampleType::class,
81
+ AnotherCustomExampleType::class
81
82
]
82
83
]);
83
-
84
+
85
+ $ graphql_types = GraphQL::getTypes ();
86
+ $ schema_types = $ schema ->getTypeMap ();
87
+
84
88
$ this ->assertGraphQLSchema ($ schema );
85
89
$ this ->assertGraphQLSchemaHasQuery ($ schema , 'examplesCustom ' );
86
90
$ this ->assertGraphQLSchemaHasMutation ($ schema , 'updateExampleCustom ' );
87
- $ this ->assertArrayHasKey ('CustomExample ' , $ schema ->getTypeMap ());
91
+ $ this ->assertArrayHasKey ('CustomExample ' , $ schema_types );
92
+ $ this ->assertArrayHasKey ('AnotherCustomExample ' , $ schema_types );
93
+ $ this ->assertArrayHasKey ('CustomExample ' , $ graphql_types );
94
+ $ this ->assertArrayHasKey ('AnotherCustomExample ' , $ graphql_types );
88
95
}
89
96
90
97
/**
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ use GraphQL \Type \Definition \Type ;
4
+ use Folklore \GraphQL \Support \Type as GraphQLType ;
5
+
6
+ class AnotherCustomExampleType extends GraphQLType
7
+ {
8
+
9
+ protected $ attributes = [
10
+ 'name ' => 'AnotherCustomExample ' ,
11
+ 'description ' => 'An example '
12
+ ];
13
+
14
+ public function fields ()
15
+ {
16
+ return [
17
+ 'test ' => [
18
+ 'type ' => Type::string (),
19
+ 'description ' => 'A test field '
20
+ ]
21
+ ];
22
+ }
23
+ }
You can’t perform that action at this time.
0 commit comments