@@ -55,13 +55,13 @@ discard block |
||
| 55 | 55 | 'fields' => [ |
| 56 | 56 | 'title' => [ |
| 57 | 57 | 'type' => Type::string(), |
| 58 | - 'resolve' => static function ($book) { |
|
| 58 | + 'resolve' => static function($book) { |
|
| 59 | 59 | return $book['title']; |
| 60 | 60 | }, |
| 61 | 61 | ], |
| 62 | 62 | 'author' => [ |
| 63 | 63 | 'type' => $this->personType, |
| 64 | - 'resolve' => static function ($book) { |
|
| 64 | + 'resolve' => static function($book) { |
|
| 65 | 65 | return $book['author']; |
| 66 | 66 | }, |
| 67 | 67 | ], |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | $this->schema = new Schema([ |
| 72 | 72 | 'mutation' => new ObjectType([ |
| 73 | 73 | 'name' => 'Mutation', |
| 74 | - 'fields' => function () { |
|
| 74 | + 'fields' => function() { |
|
| 75 | 75 | return [ |
| 76 | 76 | 'updateBook' => new ValidatedFieldDefinition([ |
| 77 | 77 | 'name' => 'updateBook', |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | 'bookId' => [ |
| 81 | 81 | 'type' => Type::nonNull(Type::id()), |
| 82 | 82 | 'errorCodes' => ['bookNotFound'], |
| 83 | - 'validate' => function ($bookId) { |
|
| 83 | + 'validate' => function($bookId) { |
|
| 84 | 84 | if (isset($this->data['books'][$bookId])) { |
| 85 | 85 | return 0; |
| 86 | 86 | } |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | }, |
| 90 | 90 | ], |
| 91 | 91 | ], |
| 92 | - 'resolve' => function ($value, $args) : array { |
|
| 92 | + 'resolve' => function($value, $args) : array { |
|
| 93 | 93 | return $this->data['books'][$args['bookId']]; |
| 94 | 94 | }, |
| 95 | 95 | ]), |
@@ -58,13 +58,13 @@ discard block |
||
| 58 | 58 | 'fields' => [ |
| 59 | 59 | 'title' => [ |
| 60 | 60 | 'type' => Type::string(), |
| 61 | - 'resolve' => static function ($book) { |
|
| 61 | + 'resolve' => static function($book) { |
|
| 62 | 62 | return $book['title']; |
| 63 | 63 | }, |
| 64 | 64 | ], |
| 65 | 65 | 'author' => [ |
| 66 | 66 | 'type' => $this->personType, |
| 67 | - 'resolve' => static function ($book) { |
|
| 67 | + 'resolve' => static function($book) { |
|
| 68 | 68 | return $book['author']; |
| 69 | 69 | }, |
| 70 | 70 | ], |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | 'query' => $this->query, |
| 78 | 78 | 'mutation' => new ObjectType([ |
| 79 | 79 | 'name' => 'Mutation', |
| 80 | - 'fields' => function () { |
|
| 80 | + 'fields' => function() { |
|
| 81 | 81 | return [ |
| 82 | 82 | 'updateBook' => new ValidatedFieldDefinition([ |
| 83 | 83 | 'name' => 'updateBook', |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | 'bookId' => [ |
| 87 | 87 | 'type' => Type::id(), |
| 88 | 88 | 'errorCodes' => ['bookNotFound'], |
| 89 | - 'validate' => function ($bookId) { |
|
| 89 | + 'validate' => function($bookId) { |
|
| 90 | 90 | if (isset($this->data['books'][$bookId])) { |
| 91 | 91 | return 0; |
| 92 | 92 | } |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | }, |
| 96 | 96 | ], |
| 97 | 97 | ], |
| 98 | - 'resolve' => static function ($value, $args) : bool { |
|
| 98 | + 'resolve' => static function($value, $args) : bool { |
|
| 99 | 99 | return true; |
| 100 | 100 | }, |
| 101 | 101 | ]), |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | 'title' => [ |
| 61 | 61 | 'type' => Type::string(), |
| 62 | 62 | 'description' => 'Enter a book title, no more than 10 characters in length', |
| 63 | - 'validate' => static function (string $title) { |
|
| 63 | + 'validate' => static function(string $title) { |
|
| 64 | 64 | if (strlen($title) > 10) { |
| 65 | 65 | return [1, 'book title must be less than 10 chaacters']; |
| 66 | 66 | } |
@@ -74,8 +74,8 @@ discard block |
||
| 74 | 74 | 'unknownAuthor', |
| 75 | 75 | 'authorDeceased', |
| 76 | 76 | ], |
| 77 | - 'validate' => function (string $authorId) { |
|
| 78 | - if (! isset($this->data['people'][$authorId])) { |
|
| 77 | + 'validate' => function(string $authorId) { |
|
| 78 | + if (!isset($this->data['people'][$authorId])) { |
|
| 79 | 79 | return ['unknownAuthor', 'We have no record of that author']; |
| 80 | 80 | } |
| 81 | 81 | return 0; |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | 'query' => $this->query, |
| 91 | 91 | 'mutation' => new ObjectType([ |
| 92 | 92 | 'name' => 'Mutation', |
| 93 | - 'fields' => function () { |
|
| 93 | + 'fields' => function() { |
|
| 94 | 94 | return [ |
| 95 | 95 | 'updateBook' => new ValidatedFieldDefinition([ |
| 96 | 96 | 'name' => 'updateBook', |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | 'type' => $this->bookAttributesInputType, |
| 101 | 101 | ], |
| 102 | 102 | ], |
| 103 | - 'resolve' => static function ($value, $args) : bool { |
|
| 103 | + 'resolve' => static function($value, $args) : bool { |
|
| 104 | 104 | // ... |
| 105 | 105 | // do update |
| 106 | 106 | // ... |
@@ -48,7 +48,7 @@ |
||
| 48 | 48 | public function testValidationWithNoErrorCodes() |
| 49 | 49 | { |
| 50 | 50 | $type = UserErrorsType::create([ |
| 51 | - 'validate' => static function ($value) { |
|
| 51 | + 'validate' => static function($value) { |
|
| 52 | 52 | }, |
| 53 | 53 | 'type' => Type::id(), |
| 54 | 54 | ], ['upsertSku']); |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | 'unknownUser', |
| 24 | 24 | 'userIsMinor', |
| 25 | 25 | ], |
| 26 | - 'typeSetter' => static function ($type) use (&$types) { |
|
| 26 | + 'typeSetter' => static function($type) use (&$types) { |
|
| 27 | 27 | $types[$type->name] = $type; |
| 28 | 28 | }, |
| 29 | 29 | 'type' => new IDType(['name' => 'User']), |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | ], |
| 57 | 57 | ], |
| 58 | 58 | ]), |
| 59 | - 'typeSetter' => static function ($type) use (&$types) { |
|
| 59 | + 'typeSetter' => static function($type) use (&$types) { |
|
| 60 | 60 | $types[$type->name] = $type; |
| 61 | 61 | }, |
| 62 | 62 | ], ['updateBook']); |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | ], |
| 85 | 85 | ], |
| 86 | 86 | ]), |
| 87 | - 'typeSetter' => static function ($type) use (&$types) { |
|
| 87 | + 'typeSetter' => static function($type) use (&$types) { |
|
| 88 | 88 | $types[$type->name] = $type; |
| 89 | 89 | }, |
| 90 | 90 | ], ['updateBook']); |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | { |
| 20 | 20 | $types = []; |
| 21 | 21 | new UserErrorsType([ |
| 22 | - 'validate' => static function($val) {}, |
|
| 22 | + 'validate' => static function($val) {}, |
|
| 23 | 23 | 'errorCodes' => [ |
| 24 | 24 | 'unknownUser', |
| 25 | 25 | 'userIsMinor', |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | 'name' => 'bookInput', |
| 80 | 80 | 'fields' => [ |
| 81 | 81 | 'authorId' => [ |
| 82 | - 'validate' => static function($authorId) {}, |
|
| 82 | + 'validate' => static function($authorId) {}, |
|
| 83 | 83 | 'errorCodes' => ['unknownAuthor'], |
| 84 | 84 | 'type' => Type::id(), |
| 85 | 85 | 'description' => 'An author Id', |
@@ -26,33 +26,33 @@ |
||
| 26 | 26 | GraphQL\Utils\Utils::invariant($config['type'] instanceof Type, 'Must provide type.'); |
| 27 | 27 | |
| 28 | 28 | if (isset($config['errorCodes'])) { |
| 29 | - if(isset($config['validate'])) { |
|
| 30 | - /** code property */ |
|
| 31 | - $finalFields['code'] = [ |
|
| 32 | - 'type' => $this->_set(new EnumType([ |
|
| 33 | - 'name' => $this->_nameFromPath(array_merge($path)) . 'ErrorCode', |
|
| 34 | - 'description' => 'Error code', |
|
| 35 | - 'values' => $config['errorCodes'], |
|
| 36 | - ]), $config), |
|
| 37 | - 'description' => 'An error code', |
|
| 38 | - 'resolve' => static function ($value) { |
|
| 39 | - return $value['error'][0] ?? null; |
|
| 40 | - }, |
|
| 41 | - ]; |
|
| 42 | - |
|
| 43 | - /** |
|
| 44 | - * msg property |
|
| 45 | - */ |
|
| 46 | - $finalFields['msg'] = [ |
|
| 47 | - 'type' => Type::string(), |
|
| 48 | - 'description' => 'A natural language description of the issue', |
|
| 49 | - 'resolve' => static function ($value) { |
|
| 50 | - return $value['error'][1] ?? null; |
|
| 51 | - }, |
|
| 52 | - ]; |
|
| 53 | - } else { |
|
| 54 | - throw new \Exception("If you specify errorCodes, you must also provide a validate callback"); |
|
| 55 | - } |
|
| 29 | + if(isset($config['validate'])) { |
|
| 30 | + /** code property */ |
|
| 31 | + $finalFields['code'] = [ |
|
| 32 | + 'type' => $this->_set(new EnumType([ |
|
| 33 | + 'name' => $this->_nameFromPath(array_merge($path)) . 'ErrorCode', |
|
| 34 | + 'description' => 'Error code', |
|
| 35 | + 'values' => $config['errorCodes'], |
|
| 36 | + ]), $config), |
|
| 37 | + 'description' => 'An error code', |
|
| 38 | + 'resolve' => static function ($value) { |
|
| 39 | + return $value['error'][0] ?? null; |
|
| 40 | + }, |
|
| 41 | + ]; |
|
| 42 | + |
|
| 43 | + /** |
|
| 44 | + * msg property |
|
| 45 | + */ |
|
| 46 | + $finalFields['msg'] = [ |
|
| 47 | + 'type' => Type::string(), |
|
| 48 | + 'description' => 'A natural language description of the issue', |
|
| 49 | + 'resolve' => static function ($value) { |
|
| 50 | + return $value['error'][1] ?? null; |
|
| 51 | + }, |
|
| 52 | + ]; |
|
| 53 | + } else { |
|
| 54 | + throw new \Exception("If you specify errorCodes, you must also provide a validate callback"); |
|
| 55 | + } |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | $type = $config['type']; |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | GraphQL\Utils\Utils::invariant($config['type'] instanceof Type, 'Must provide type.'); |
| 27 | 27 | |
| 28 | 28 | if (isset($config['errorCodes'])) { |
| 29 | - if(isset($config['validate'])) { |
|
| 29 | + if (isset($config['validate'])) { |
|
| 30 | 30 | /** code property */ |
| 31 | 31 | $finalFields['code'] = [ |
| 32 | 32 | 'type' => $this->_set(new EnumType([ |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | 'values' => $config['errorCodes'], |
| 36 | 36 | ]), $config), |
| 37 | 37 | 'description' => 'An error code', |
| 38 | - 'resolve' => static function ($value) { |
|
| 38 | + 'resolve' => static function($value) { |
|
| 39 | 39 | return $value['error'][0] ?? null; |
| 40 | 40 | }, |
| 41 | 41 | ]; |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | $finalFields['msg'] = [ |
| 47 | 47 | 'type' => Type::string(), |
| 48 | 48 | 'description' => 'A natural language description of the issue', |
| 49 | - 'resolve' => static function ($value) { |
|
| 49 | + 'resolve' => static function($value) { |
|
| 50 | 50 | return $value['error'][1] ?? null; |
| 51 | 51 | }, |
| 52 | 52 | ]; |
@@ -60,18 +60,18 @@ discard block |
||
| 60 | 60 | $fields = []; |
| 61 | 61 | foreach ($type->getFields() as $key => $field) { |
| 62 | 62 | $newType = static::create( |
| 63 | - $field->config + ['typeSetter' => $config['typeSetter'] ?? null], |
|
| 63 | + $field->config+['typeSetter' => $config['typeSetter'] ?? null], |
|
| 64 | 64 | array_merge($path, [$key]) |
| 65 | 65 | ); |
| 66 | 66 | |
| 67 | - if (! $newType) { |
|
| 67 | + if (!$newType) { |
|
| 68 | 68 | continue; |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | $fields[$key] = [ |
| 72 | 72 | 'description' => 'Error for ' . $key, |
| 73 | 73 | 'type' => $newType, |
| 74 | - 'resolve' => static function ($value) use ($key) { |
|
| 74 | + 'resolve' => static function($value) use ($key) { |
|
| 75 | 75 | return $value[$key] ?? null; |
| 76 | 76 | }, |
| 77 | 77 | ]; |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | 'fields' => $fields, |
| 89 | 89 | ]), $config), |
| 90 | 90 | 'description' => 'Suberrors for ' . ucfirst($path[count($path)-1]), |
| 91 | - 'resolve' => static function (array $value) { |
|
| 91 | + 'resolve' => static function(array $value) { |
|
| 92 | 92 | return $value['suberrors'] ?? null; |
| 93 | 93 | }, |
| 94 | 94 | ]; |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | $finalFields['suberrors'] = [ |
| 113 | 113 | 'description' => 'Suberrors for the list of ' . $type->ofType . ' items', |
| 114 | 114 | 'type' => $newType, |
| 115 | - 'resolve' => static function ($value) { |
|
| 115 | + 'resolve' => static function($value) { |
|
| 116 | 116 | return $value['suberrors'] ?? null; |
| 117 | 117 | }, |
| 118 | 118 | ]; |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | $finalFields['path'] = [ |
| 127 | 127 | 'type' => Type::listOf(Type::int()), |
| 128 | 128 | 'description' => 'A path describing this items\'s location in the nested array', |
| 129 | - 'resolve' => static function ($value) { |
|
| 129 | + 'resolve' => static function($value) { |
|
| 130 | 130 | return $value['path']; |
| 131 | 131 | }, |
| 132 | 132 | ]; |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | $config['fields']['code'] = $config['fields']['code'] ?? [ |
| 164 | 164 | 'type' => Type::int(), |
| 165 | 165 | 'description' => 'A numeric error code. 0 on success, non-zero on failure.', |
| 166 | - 'resolve' => static function ($value) { |
|
| 166 | + 'resolve' => static function($value) { |
|
| 167 | 167 | $error = $value['error'] ?? null; |
| 168 | 168 | switch (gettype($error)) { |
| 169 | 169 | case 'integer': |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | $config['fields']['msg'] = $config['fields']['msg'] ?? [ |
| 177 | 177 | 'type' => Type::string(), |
| 178 | 178 | 'description' => 'An error message.', |
| 179 | - 'resolve' => static function ($value) { |
|
| 179 | + 'resolve' => static function($value) { |
|
| 180 | 180 | $error = $value['error'] ?? null; |
| 181 | 181 | switch (gettype($error)) { |
| 182 | 182 | case 'integer': |
@@ -90,11 +90,11 @@ |
||
| 90 | 90 | ]); |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | - protected function _isAssoc(array $arr) |
|
| 94 | - { |
|
| 95 | - if (array() === $arr) return false; |
|
| 96 | - return array_keys($arr) !== range(0, count($arr) - 1); |
|
| 97 | - } |
|
| 93 | + protected function _isAssoc(array $arr) |
|
| 94 | + { |
|
| 95 | + if (array() === $arr) return false; |
|
| 96 | + return array_keys($arr) !== range(0, count($arr) - 1); |
|
| 97 | + } |
|
| 98 | 98 | |
| 99 | 99 | protected function _validateItems($value, array $path, callable $validate) { |
| 100 | 100 | foreach ($value as $idx => $subValue) { |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | |
| 38 | 38 | $this->typeSetter = $config['typeSetter'] ?? null; |
| 39 | 39 | |
| 40 | - if (! isset($config['type'])) { |
|
| 40 | + if (!isset($config['type'])) { |
|
| 41 | 41 | throw new Exception('You must specify a type for your field'); |
| 42 | 42 | } |
| 43 | 43 | |
@@ -47,14 +47,14 @@ discard block |
||
| 47 | 47 | 'result' => [ |
| 48 | 48 | 'type' => $config['type'], |
| 49 | 49 | 'description' => 'The payload, if any', |
| 50 | - 'resolve' => static function ($value) { |
|
| 50 | + 'resolve' => static function($value) { |
|
| 51 | 51 | return $value['result'] ?? null; |
| 52 | 52 | }, |
| 53 | 53 | ], |
| 54 | 54 | 'valid' => [ |
| 55 | 55 | 'type' => Type::nonNull(Type::boolean()), |
| 56 | 56 | 'description' => 'Whether all validation passed. True for yes, false for no.', |
| 57 | - 'resolve' => static function ($value) { |
|
| 57 | + 'resolve' => static function($value) { |
|
| 58 | 58 | return $value['valid']; |
| 59 | 59 | }, |
| 60 | 60 | ], |
@@ -71,17 +71,17 @@ discard block |
||
| 71 | 71 | 'type' => $type, |
| 72 | 72 | 'args' => $args, |
| 73 | 73 | 'name' => $name, |
| 74 | - 'resolve' => function ($value, $args1, $context, $info) use ($config, $args) { |
|
| 74 | + 'resolve' => function($value, $args1, $context, $info) use ($config, $args) { |
|
| 75 | 75 | // validate inputs |
| 76 | - $config['type'] = new InputObjectType([ |
|
| 76 | + $config['type'] = new InputObjectType([ |
|
| 77 | 77 | 'name'=>'', |
| 78 | 78 | 'fields' => $args, |
| 79 | 79 | ]); |
| 80 | 80 | $errors = $this->_validate($config, $args1); |
| 81 | 81 | $result = $errors; |
| 82 | - $result['valid'] = ! $errors; |
|
| 82 | + $result['valid'] = !$errors; |
|
| 83 | 83 | |
| 84 | - if (! isset($result['error']) && ! isset($result['suberrors'])) { |
|
| 84 | + if (!isset($result['error']) && !isset($result['suberrors'])) { |
|
| 85 | 85 | $result['result'] = $config['resolve']($value, $args1, $context, $info); |
| 86 | 86 | } |
| 87 | 87 | |
@@ -93,19 +93,19 @@ discard block |
||
| 93 | 93 | protected function _isAssoc(array $arr) |
| 94 | 94 | { |
| 95 | 95 | if (array() === $arr) return false; |
| 96 | - return array_keys($arr) !== range(0, count($arr) - 1); |
|
| 96 | + return array_keys($arr) !== range(0, count($arr)-1); |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | protected function _validateItems($value, array $path, callable $validate) { |
| 100 | 100 | foreach ($value as $idx => $subValue) { |
| 101 | - if(is_array($subValue) && !$this->_isAssoc($subValue)) { |
|
| 101 | + if (is_array($subValue) && !$this->_isAssoc($subValue)) { |
|
| 102 | 102 | $path[count($path)-1] = $idx; |
| 103 | 103 | $newPath = $path; |
| 104 | 104 | $newPath[] = 0; |
| 105 | 105 | $this->_validateItems($subValue, $newPath, $validate); |
| 106 | 106 | } |
| 107 | 107 | else { |
| 108 | - $path[count($path) - 1] = $idx; |
|
| 108 | + $path[count($path)-1] = $idx; |
|
| 109 | 109 | $err = $validate($subValue); |
| 110 | 110 | |
| 111 | 111 | if ($err) { |
@@ -133,11 +133,11 @@ discard block |
||
| 133 | 133 | } |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | - if(isset($arg['validateItem'])) { |
|
| 136 | + if (isset($arg['validateItem'])) { |
|
| 137 | 137 | try { |
| 138 | 138 | $this->_validateItems($value, [0], $arg['validateItem']); |
| 139 | 139 | } |
| 140 | - catch(ValidateItemsError $e) { |
|
| 140 | + catch (ValidateItemsError $e) { |
|
| 141 | 141 | $res['suberrors'] = [ |
| 142 | 142 | 'error' => $e->error, |
| 143 | 143 | 'path' => $e->path |
@@ -92,7 +92,9 @@ discard block |
||
| 92 | 92 | |
| 93 | 93 | protected function _isAssoc(array $arr) |
| 94 | 94 | { |
| 95 | - if (array() === $arr) return false; |
|
| 95 | + if (array() === $arr) { |
|
| 96 | + return false; |
|
| 97 | + } |
|
| 96 | 98 | return array_keys($arr) !== range(0, count($arr) - 1); |
| 97 | 99 | } |
| 98 | 100 | |
@@ -103,8 +105,7 @@ discard block |
||
| 103 | 105 | $newPath = $path; |
| 104 | 106 | $newPath[] = 0; |
| 105 | 107 | $this->_validateItems($subValue, $newPath, $validate); |
| 106 | - } |
|
| 107 | - else { |
|
| 108 | + } else { |
|
| 108 | 109 | $path[count($path) - 1] = $idx; |
| 109 | 110 | $err = $validate($subValue); |
| 110 | 111 | |
@@ -136,8 +137,7 @@ discard block |
||
| 136 | 137 | if(isset($arg['validateItem'])) { |
| 137 | 138 | try { |
| 138 | 139 | $this->_validateItems($value, [0], $arg['validateItem']); |
| 139 | - } |
|
| 140 | - catch(ValidateItemsError $e) { |
|
| 140 | + } catch(ValidateItemsError $e) { |
|
| 141 | 141 | $res['suberrors'] = [ |
| 142 | 142 | 'error' => $e->error, |
| 143 | 143 | 'path' => $e->path |
@@ -22,7 +22,7 @@ |
||
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | // Toss out the first and last lines. |
| 25 | - $lines = array_slice($lines, 1, count($lines) - 2); |
|
| 25 | + $lines = array_slice($lines, 1, count($lines)-2); |
|
| 26 | 26 | |
| 27 | 27 | // take the tabs from the first line, and subtract them from all lines |
| 28 | 28 | $matches = []; |
@@ -45,9 +45,9 @@ discard block |
||
| 45 | 45 | |
| 46 | 46 | public function testFieldsWithErrorCodesButNoValidate() |
| 47 | 47 | { |
| 48 | - $this->expectExceptionMessage("If you specify errorCodes, you must also provide a validate callback"); |
|
| 48 | + $this->expectExceptionMessage("If you specify errorCodes, you must also provide a validate callback"); |
|
| 49 | 49 | |
| 50 | - $type = new UserErrorsType([ |
|
| 50 | + $type = new UserErrorsType([ |
|
| 51 | 51 | 'type' => new InputObjectType([ |
| 52 | 52 | 'name' => 'bookInput', |
| 53 | 53 | 'fields' => [ |
@@ -61,25 +61,25 @@ discard block |
||
| 61 | 61 | ], ['updateBook']); |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | - public function testFieldsWithValidate() |
|
| 65 | - { |
|
| 66 | - $type = new UserErrorsType([ |
|
| 67 | - 'type' => new InputObjectType([ |
|
| 68 | - 'name' => 'bookInput', |
|
| 69 | - 'fields' => [ |
|
| 70 | - 'authorId' => [ |
|
| 71 | - 'errorCodes' => ['unknownAuthor'], |
|
| 72 | - 'validate' => static function(int $authorId) { |
|
| 64 | + public function testFieldsWithValidate() |
|
| 65 | + { |
|
| 66 | + $type = new UserErrorsType([ |
|
| 67 | + 'type' => new InputObjectType([ |
|
| 68 | + 'name' => 'bookInput', |
|
| 69 | + 'fields' => [ |
|
| 70 | + 'authorId' => [ |
|
| 71 | + 'errorCodes' => ['unknownAuthor'], |
|
| 72 | + 'validate' => static function(int $authorId) { |
|
| 73 | 73 | |
| 74 | - }, |
|
| 75 | - 'type' => Type::id(), |
|
| 76 | - 'description' => 'An author Id', |
|
| 77 | - ], |
|
| 78 | - ], |
|
| 79 | - ]) |
|
| 80 | - ], ['updateBook']); |
|
| 74 | + }, |
|
| 75 | + 'type' => Type::id(), |
|
| 76 | + 'description' => 'An author Id', |
|
| 77 | + ], |
|
| 78 | + ], |
|
| 79 | + ]) |
|
| 80 | + ], ['updateBook']); |
|
| 81 | 81 | |
| 82 | - self::assertEquals(Utils::nowdoc(' |
|
| 82 | + self::assertEquals(Utils::nowdoc(' |
|
| 83 | 83 | schema { |
| 84 | 84 | query: UpdateBookError |
| 85 | 85 | } |
@@ -111,5 +111,5 @@ discard block |
||
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | '), SchemaPrinter::doPrint(new Schema(['query' => $type]))); |
| 114 | - } |
|
| 114 | + } |
|
| 115 | 115 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | { |
| 18 | 18 | public function testFieldsWithNoErrorCodes() |
| 19 | 19 | { |
| 20 | - $type = new UserErrorsType([ |
|
| 20 | + $type = new UserErrorsType([ |
|
| 21 | 21 | 'type' => new InputObjectType([ |
| 22 | 22 | 'name' => 'bookInput', |
| 23 | 23 | 'fields' => [ |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | { |
| 48 | 48 | $this->expectExceptionMessage("If you specify errorCodes, you must also provide a validate callback"); |
| 49 | 49 | |
| 50 | - $type = new UserErrorsType([ |
|
| 50 | + $type = new UserErrorsType([ |
|
| 51 | 51 | 'type' => new InputObjectType([ |
| 52 | 52 | 'name' => 'bookInput', |
| 53 | 53 | 'fields' => [ |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | |
| 64 | 64 | public function testFieldsWithValidate() |
| 65 | 65 | { |
| 66 | - $type = new UserErrorsType([ |
|
| 66 | + $type = new UserErrorsType([ |
|
| 67 | 67 | 'type' => new InputObjectType([ |
| 68 | 68 | 'name' => 'bookInput', |
| 69 | 69 | 'fields' => [ |