| @@ 303-310 (lines=8) @@ | ||
| 300 | $currentType = $queryType->getNullableType(); |
|
| 301 | ||
| 302 | ||
| 303 | if ($currentType->getKind() == TypeMap::KIND_SCALAR) { |
|
| 304 | if (!$query->hasFields()) { |
|
| 305 | return $this->getOutputValue($currentType, $resolvedValue); |
|
| 306 | } else { |
|
| 307 | $this->executionContext->addError(new ResolveException(sprintf('Fields are not found in query "%s"', $query->getName()))); |
|
| 308 | ||
| 309 | return null; |
|
| 310 | } |
|
| 311 | } |
|
| 312 | ||
| 313 | foreach ($query->getFields() as $fieldAst) { |
|
| @@ 239-245 (lines=7) @@ | ||
| 236 | public function isValidValueForField(FieldInterface $field, $value) |
|
| 237 | { |
|
| 238 | $fieldType = $field->getType(); |
|
| 239 | if ($fieldType->getKind() == TypeMap::KIND_NON_NULL && is_null($value)) { |
|
| 240 | $this->executionContext->addError(new ResolveException(sprintf('Cannot return null for non-nullable field %s', $field->getName()))); |
|
| 241 | ||
| 242 | return null; |
|
| 243 | } else { |
|
| 244 | $fieldType = $this->resolveTypeIfAbstract($fieldType->getNullableType(), $value); |
|
| 245 | } |
|
| 246 | ||
| 247 | if (!is_null($value) && !$fieldType->isValidValue($value)) { |
|
| 248 | $this->executionContext->addError(new ResolveException(sprintf('Not valid value for %s field %s', $fieldType->getNullableType()->getKind(), $field->getName()))); |
|