Code Duplication    Length = 7-8 lines in 2 locations

src/Validator/ResolveValidator/ResolveValidator.php 1 location

@@ 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())));

src/Execution/Processor.php 1 location

@@ 304-311 (lines=8) @@
301
    {
302
        $currentType = $queryType->getNullableType();
303
304
        if ($currentType->getKind() == TypeMap::KIND_SCALAR) {
305
            if (!$query->hasFields()) {
306
                return $this->getOutputValue($currentType, $resolvedValue);
307
            } else {
308
                $this->executionContext->addError(new ResolveException(sprintf('Fields are not found in query "%s"', $query->getName())));
309
310
                return null;
311
            }
312
        }
313
314
        foreach ($query->getFields() as $fieldAst) {