| @@ 194-200 (lines=7) @@ | ||
| 191 | public function isValidValueForField(AbstractField $field, $value) |
|
| 192 | { |
|
| 193 | $fieldType = $field->getType(); |
|
| 194 | if ($fieldType->getKind() == TypeMap::KIND_NON_NULL && is_null($value)) { |
|
| 195 | $this->executionContext->addError(new ResolveException(sprintf('Cannot return null for non-nullable field %s', $field->getName()))); |
|
| 196 | ||
| 197 | return null; |
|
| 198 | } else { |
|
| 199 | $fieldType = $this->resolveTypeIfAbstract($fieldType->getNullableType(), $value); |
|
| 200 | } |
|
| 201 | ||
| 202 | if (!is_null($value) && !$fieldType->isValidValue($value)) { |
|
| 203 | $this->executionContext->addError(new ResolveException(sprintf('Not valid value for %s field %s', $fieldType->getNullableType()->getKind(), $field->getName()))); |
|
| @@ 309-316 (lines=8) @@ | ||
| 306 | { |
|
| 307 | $currentType = $queryType->getNullableType(); |
|
| 308 | ||
| 309 | if ($currentType->getKind() == TypeMap::KIND_SCALAR) { |
|
| 310 | if (!$query->hasFields()) { |
|
| 311 | return $this->getOutputValue($currentType, $resolvedValue); |
|
| 312 | } else { |
|
| 313 | $this->executionContext->addError(new ResolveException(sprintf('Fields are not found in query "%s"', $query->getName()))); |
|
| 314 | ||
| 315 | return null; |
|
| 316 | } |
|
| 317 | } |
|
| 318 | ||
| 319 | foreach ($query->getFields() as $fieldAst) { |
|