@@ -24,7 +24,7 @@ |
||
| 24 | 24 | } |
| 25 | 25 | $this->memo += $cost ?: $this->defaultScore; |
| 26 | 26 | if ($this->memo > $this->maxScore) { |
| 27 | - throw new \Exception('query exceeded max allowed complexity of ' . $this->maxScore); |
|
| 27 | + throw new \Exception('query exceeded max allowed complexity of '.$this->maxScore); |
|
| 28 | 28 | } |
| 29 | 29 | return $this->memo; |
| 30 | 30 | } |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | |
| 125 | 125 | public function testSchemaOperations() |
| 126 | 126 | { |
| 127 | - $schema = new Schema([ |
|
| 127 | + $schema = new Schema([ |
|
| 128 | 128 | 'query' => new ObjectType([ |
| 129 | 129 | 'name' => 'RootQuery', |
| 130 | 130 | 'fields' => [ |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | 'args' => [ |
| 138 | 138 | 'shorten' => new BooleanType() |
| 139 | 139 | ], |
| 140 | - 'resolve' => function ($value, $args) { |
|
| 140 | + 'resolve' => function($value, $args) { |
|
| 141 | 141 | return empty($args['shorten']) ? $value : $value; |
| 142 | 142 | } |
| 143 | 143 | ], |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | 'code' => new StringType(), |
| 146 | 146 | ] |
| 147 | 147 | ]), |
| 148 | - 'resolve' => function ($value, $args) { |
|
| 148 | + 'resolve' => function($value, $args) { |
|
| 149 | 149 | $data = ['firstName' => 'John', 'code' => '007']; |
| 150 | 150 | if (!empty($args['upper'])) { |
| 151 | 151 | foreach ($data as $key => $value) { |
@@ -164,13 +164,13 @@ discard block |
||
| 164 | 164 | ], |
| 165 | 165 | 'randomUser' => [ |
| 166 | 166 | 'type' => new TestObjectType(), |
| 167 | - 'resolve' => function () { |
|
| 167 | + 'resolve' => function() { |
|
| 168 | 168 | return ['invalidField' => 'John']; |
| 169 | 169 | } |
| 170 | 170 | ], |
| 171 | 171 | 'invalidValueQuery' => [ |
| 172 | 172 | 'type' => new TestObjectType(), |
| 173 | - 'resolve' => function () { |
|
| 173 | + 'resolve' => function() { |
|
| 174 | 174 | return 'stringValue'; |
| 175 | 175 | } |
| 176 | 176 | ], |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | ->addField(new Field([ |
| 196 | 196 | 'name' => 'increaseCounter', |
| 197 | 197 | 'type' => new IntType(), |
| 198 | - 'resolve' => function ($value, $args, ResolveInfo $info) { |
|
| 198 | + 'resolve' => function($value, $args, ResolveInfo $info) { |
|
| 199 | 199 | return $this->_counter += $args['amount']; |
| 200 | 200 | }, |
| 201 | 201 | 'args' => [ |
@@ -207,13 +207,13 @@ discard block |
||
| 207 | 207 | ]))->addField(new Field([ |
| 208 | 208 | 'name' => 'invalidResolveTypeMutation', |
| 209 | 209 | 'type' => new NonNullType(new IntType()), |
| 210 | - 'resolve' => function () { |
|
| 210 | + 'resolve' => function() { |
|
| 211 | 211 | return null; |
| 212 | 212 | } |
| 213 | 213 | ]))->addField(new Field([ |
| 214 | 214 | 'name' => 'interfacedMutation', |
| 215 | 215 | 'type' => new TestInterfaceType(), |
| 216 | - 'resolve' => function () { |
|
| 216 | + 'resolve' => function() { |
|
| 217 | 217 | return ['name' => 'John']; |
| 218 | 218 | } |
| 219 | 219 | ])); |
@@ -259,43 +259,43 @@ discard block |
||
| 259 | 259 | 'fields' => [ |
| 260 | 260 | 'listQuery' => [ |
| 261 | 261 | 'type' => new ListType(new TestEnumType()), |
| 262 | - 'resolve' => function () { |
|
| 262 | + 'resolve' => function() { |
|
| 263 | 263 | return 'invalid list'; |
| 264 | 264 | } |
| 265 | 265 | ], |
| 266 | 266 | 'listEnumQuery' => [ |
| 267 | 267 | 'type' => new ListType(new TestEnumType()), |
| 268 | - 'resolve' => function () { |
|
| 268 | + 'resolve' => function() { |
|
| 269 | 269 | return ['invalid enum']; |
| 270 | 270 | } |
| 271 | 271 | ], |
| 272 | 272 | 'invalidEnumQuery' => [ |
| 273 | 273 | 'type' => new TestEnumType(), |
| 274 | - 'resolve' => function () { |
|
| 274 | + 'resolve' => function() { |
|
| 275 | 275 | return 'invalid enum'; |
| 276 | 276 | } |
| 277 | 277 | ], |
| 278 | 278 | 'enumQuery' => [ |
| 279 | 279 | 'type' => new TestEnumType(), |
| 280 | - 'resolve' => function () { |
|
| 280 | + 'resolve' => function() { |
|
| 281 | 281 | return 1; |
| 282 | 282 | } |
| 283 | 283 | ], |
| 284 | 284 | 'invalidNonNullQuery' => [ |
| 285 | 285 | 'type' => new NonNullType(new IntType()), |
| 286 | - 'resolve' => function () { |
|
| 286 | + 'resolve' => function() { |
|
| 287 | 287 | return null; |
| 288 | 288 | } |
| 289 | 289 | ], |
| 290 | 290 | 'invalidNonNullInsideQuery' => [ |
| 291 | 291 | 'type' => new NonNullType(new IntType()), |
| 292 | - 'resolve' => function () { |
|
| 292 | + 'resolve' => function() { |
|
| 293 | 293 | return 'hello'; |
| 294 | 294 | } |
| 295 | 295 | ], |
| 296 | 296 | 'objectQuery' => [ |
| 297 | 297 | 'type' => new TestObjectType(), |
| 298 | - 'resolve' => function () { |
|
| 298 | + 'resolve' => function() { |
|
| 299 | 299 | return ['name' => 'John']; |
| 300 | 300 | } |
| 301 | 301 | ], |
@@ -307,7 +307,7 @@ discard block |
||
| 307 | 307 | 'enum' => new TestEnumType(), |
| 308 | 308 | ], |
| 309 | 309 | ]), |
| 310 | - 'resolve' => function () { |
|
| 310 | + 'resolve' => function() { |
|
| 311 | 311 | return [ |
| 312 | 312 | 'object' => [ |
| 313 | 313 | 'name' => 'John' |
@@ -376,10 +376,10 @@ discard block |
||
| 376 | 376 | ] |
| 377 | 377 | ]); |
| 378 | 378 | |
| 379 | - $union = new UnionType([ |
|
| 379 | + $union = new UnionType([ |
|
| 380 | 380 | 'name' => 'TestUnion', |
| 381 | 381 | 'types' => [$object1, $object2], |
| 382 | - 'resolveType' => function ($object) use ($object1, $object2) { |
|
| 382 | + 'resolveType' => function($object) use ($object1, $object2) { |
|
| 383 | 383 | if (isset($object['id'])) { |
| 384 | 384 | return $object1; |
| 385 | 385 | } |
@@ -390,11 +390,11 @@ discard block |
||
| 390 | 390 | $invalidUnion = new UnionType([ |
| 391 | 391 | 'name' => 'TestUnion', |
| 392 | 392 | 'types' => [$object1, $object2], |
| 393 | - 'resolveType' => function ($object) use ($object3) { |
|
| 393 | + 'resolveType' => function($object) use ($object3) { |
|
| 394 | 394 | return $object3; |
| 395 | 395 | } |
| 396 | 396 | ]); |
| 397 | - $processor = new Processor(new Schema([ |
|
| 397 | + $processor = new Processor(new Schema([ |
|
| 398 | 398 | 'query' => new ObjectType([ |
| 399 | 399 | 'name' => 'RootQuery', |
| 400 | 400 | 'fields' => [ |
@@ -403,7 +403,7 @@ discard block |
||
| 403 | 403 | 'args' => [ |
| 404 | 404 | 'type' => ['type' => 'string'] |
| 405 | 405 | ], |
| 406 | - 'resolve' => function ($value, $args) { |
|
| 406 | + 'resolve' => function($value, $args) { |
|
| 407 | 407 | if ($args['type'] == 'object1') { |
| 408 | 408 | return [ |
| 409 | 409 | 'id' => 43 |
@@ -417,7 +417,7 @@ discard block |
||
| 417 | 417 | ], |
| 418 | 418 | 'invalidUnion' => [ |
| 419 | 419 | 'type' => $invalidUnion, |
| 420 | - 'resolve' => function () { |
|
| 420 | + 'resolve' => function() { |
|
| 421 | 421 | return ['name' => 'name resolved']; |
| 422 | 422 | } |
| 423 | 423 | ], |
@@ -465,7 +465,7 @@ discard block |
||
| 465 | 465 | 'args' => [ |
| 466 | 466 | 'shorten' => new BooleanType() |
| 467 | 467 | ], |
| 468 | - 'resolve' => function ($value, $args) { |
|
| 468 | + 'resolve' => function($value, $args) { |
|
| 469 | 469 | return empty($args['shorten']) ? $value : $value; |
| 470 | 470 | } |
| 471 | 471 | ], |
@@ -474,14 +474,14 @@ discard block |
||
| 474 | 474 | 'likes' => [ |
| 475 | 475 | 'type' => new IntType(), |
| 476 | 476 | 'cost' => 10, |
| 477 | - 'resolve' => function () { |
|
| 477 | + 'resolve' => function() { |
|
| 478 | 478 | return 42; |
| 479 | 479 | } |
| 480 | 480 | ] |
| 481 | 481 | ] |
| 482 | 482 | ] |
| 483 | 483 | ), |
| 484 | - 'resolve' => function ($value, $args) { |
|
| 484 | + 'resolve' => function($value, $args) { |
|
| 485 | 485 | $data = ['firstName' => 'John', 'code' => '007']; |
| 486 | 486 | if (!empty($args['upper'])) { |
| 487 | 487 | foreach ($data as $key => $value) { |