@@ -112,7 +112,7 @@ public function testGetSchema(bool $paginationEnabled)
112
112
),
113
113
"{$ builtinType }Description " ,
114
114
true ,
115
- null ,
115
+ true ,
116
116
null ,
117
117
null ,
118
118
null
@@ -121,6 +121,7 @@ public function testGetSchema(bool $paginationEnabled)
121
121
$ mockedSchemaBuilder = $ this ->createSchemaBuilder ($ propertyMetadataMockBuilder , $ paginationEnabled );
122
122
$ schema = $ mockedSchemaBuilder ->getSchema ();
123
123
$ queryFields = $ schema ->getConfig ()->getQuery ()->getFields ();
124
+ $ mutationFields = $ schema ->getConfig ()->getMutation ()->getFields ();
124
125
125
126
$ this ->assertEquals ([
126
127
'node ' ,
@@ -132,11 +133,17 @@ public function testGetSchema(bool $paginationEnabled)
132
133
'shortName3s ' ,
133
134
], array_keys ($ queryFields ));
134
135
136
+ $ this ->assertEquals ([
137
+ 'createShortName1 ' ,
138
+ 'createShortName2 ' ,
139
+ 'createShortName3 ' ,
140
+ ], array_keys ($ mutationFields ));
141
+
135
142
/** @var ObjectType $type */
136
143
$ type = $ queryFields ['shortName2 ' ]->getType ();
137
144
$ resourceTypeFields = $ type ->getFields ();
138
145
$ this ->assertEquals (
139
- ['id ' , 'intProperty ' , 'floatProperty ' , 'stringProperty ' , 'boolProperty ' , 'objectProperty ' , 'arrayProperty ' , 'iterableProperty ' ],
146
+ ['id ' , '_id ' , 'floatProperty ' , 'stringProperty ' , 'boolProperty ' , 'objectProperty ' , 'arrayProperty ' , 'iterableProperty ' ],
140
147
array_keys ($ resourceTypeFields )
141
148
);
142
149
@@ -171,6 +178,14 @@ public function testGetSchema(bool $paginationEnabled)
171
178
/** @var ListOfType $objectPropertyFieldType */
172
179
$ objectPropertyFieldType = $ type ->getFields ()['objectProperty ' ]->getType ();
173
180
$ this ->assertEquals (GraphQLType::nonNull (GraphQLType::string ()), $ objectPropertyFieldType );
181
+
182
+ /** @var ObjectType $type */
183
+ $ type = $ mutationFields ['createShortName2 ' ]->getType ();
184
+ $ resourceTypeFields = $ type ->getFields ();
185
+ $ this ->assertEquals (
186
+ ['id ' , '_id ' , 'floatProperty ' , 'stringProperty ' , 'boolProperty ' , 'objectProperty ' , 'arrayProperty ' , 'iterableProperty ' , 'clientMutationId ' ],
187
+ array_keys ($ resourceTypeFields )
188
+ );
174
189
}
175
190
176
191
public function paginationProvider (): array
@@ -202,16 +217,17 @@ private function createSchemaBuilder($propertyMetadataMockBuilder, bool $paginat
202
217
null ,
203
218
null ,
204
219
null ,
205
- ['query ' => []]
220
+ ['query ' => [], ' create ' => [] ]
206
221
);
207
222
$ resourceMetadataFactoryProphecy ->create ($ resourceClassName )->willReturn ($ resourceMetadata );
208
223
$ resourceMetadataFactoryProphecy ->create ('unknownResource ' )->willThrow (new ResourceClassNotFoundException ());
209
224
210
225
$ propertyNames = [];
211
226
foreach (Type::$ builtinTypes as $ builtinType ) {
212
- $ propertyName = "{$ builtinType }Property " ;
227
+ $ propertyName = Type:: BUILTIN_TYPE_INT === $ builtinType ? ' id ' : "{$ builtinType }Property " ;
213
228
$ propertyNames [] = $ propertyName ;
214
- $ propertyMetadataFactoryProphecy ->create ($ resourceClassName , $ propertyName )->willReturn ($ propertyMetadataMockBuilder ($ builtinType , $ resourceClassName ));
229
+ $ propertyMetadataFactoryProphecy ->create ($ resourceClassName , $ propertyName , ['graphql_operation_name ' => 'query ' ])->willReturn ($ propertyMetadataMockBuilder ($ builtinType , $ resourceClassName ));
230
+ $ propertyMetadataFactoryProphecy ->create ($ resourceClassName , $ propertyName , ['graphql_operation_name ' => 'create ' ])->willReturn ($ propertyMetadataMockBuilder ($ builtinType , $ resourceClassName ));
215
231
}
216
232
$ propertyNameCollection = new PropertyNameCollection ($ propertyNames );
217
233
$ propertyNameCollectionFactoryProphecy ->create ($ resourceClassName )->willReturn ($ propertyNameCollection );
0 commit comments