Resolve the field directive.

@param  \Nuwave\Lighthouse\Schema\Values\FieldValue  $fieldValue
@return \Nuwave\Lighthouse\Schema\Values\FieldValue
321291
public function resolveField(FieldValue $fieldValue): FieldValue
    {
        /** @var string|null $guard */
        $guard = $this->directiveArgValue('guard');

        return $fieldValue->setResolver(
            function () use ($guard): ?Authenticatable {
                return $this
                    ->authFactory
                    ->guard($guard)
                    ->user();
            }
        );
    }
757245
public function resolveField(FieldValue $fieldValue): FieldValue
    {
        [$className, $methodName] = $this->getMethodArgumentParts('resolver');

        $namespacedClassName = $this->namespaceClassName(
            $className,
            $fieldValue->defaultNamespacesForParent()
        );

        $resolver = Utils::constructResolver($namespacedClassName, $methodName);

        $additionalData = $this->directiveArgValue('args');

        return $fieldValue->setResolver(
            function ($root, array $args, GraphQLContext $context, ResolveInfo $resolveInfo) use ($resolver, $additionalData) {
                return $resolver(
                    $root,
                    array_merge($args, ['directive' => $additionalData]),
                    $context,
                    $resolveInfo
                );
            }
        );
    }
182178
public function isEmptyValue(FieldValue $fieldValue)
    {
        return $this->internalFieldType->isEmptyValue(
            $this->internalFieldType->fromPersistenceValue($fieldValue)
        );
    }
750401
public function fromPersistenceValue(FieldValue $fieldValue)
    {
        if ($fieldValue->externalData === null) {
            return $this->getEmptyValue();
        }

        $result = parent::fromPersistenceValue($fieldValue);

        $result->hasController = (isset($fieldValue->externalData['hasController'])
            ? $fieldValue->externalData['hasController']
            : false);
        $result->autoplay = (isset($fieldValue->externalData['autoplay'])
            ? $fieldValue->externalData['autoplay']
            : false);
        $result->loop = (isset($fieldValue->externalData['loop'])
            ? $fieldValue->externalData['loop']
            : false);
        $result->height = (isset($fieldValue->externalData['height'])
            ? $fieldValue->externalData['height']
            : 0);
        $result->width = (isset($fieldValue->externalData['width'])
            ? $fieldValue->externalData['width']
            : 0);

        return $result;
    }
1249220
protected function resolveFieldValueOrError(
        Field $field,
        FieldNode $fieldNode,
        ?callable $resolveCallback,
        $rootValue,
        ExecutionContext $context,
        ResolveInfo $info
    ) {
        try {
            // Build an associative array of arguments from the field.arguments AST, using the
            // variables scope to fulfill any variable references.
            $result = $resolveCallback(
                $rootValue,
                $this->valuesResolver->coerceArgumentValues($field, $fieldNode, $context->getVariableValues()),
                $context->getContextValue(),
                $info
            );

            if ($result instanceof PromiseInterface) {
                return $result->then(null, function ($exception) use ($fieldNode, $info) {
                    return !$exception instanceof ExecutionException
                        ? $this->normalizeException($exception, [$fieldNode], $info->getPath())
                        : $exception;
                });
            }

            return $result;
        } catch (\Throwable $exception) {
            return $exception;
        }
    }
326175
public function handleField(FieldValue $fieldValue, Closure $next): FieldValue
    {
        if ($this->directiveHasArgument('resolver')) {
            [$className, $methodName] = $this->getMethodArgumentParts('resolver');

            $namespacedClassName = $this->namespaceClassName(
                $className,
                $fieldValue->defaultNamespacesForParent()
            );

            $resolver = Utils::constructResolver($namespacedClassName, $methodName);
        } else {
            $resolver = function (int $childrenComplexity, array $args): int {
                $complexity = Arr::get(
                    $args,
                    'first',
                    Arr::get($args, config('lighthouse.pagination_amount_argument'), 1)
                );

                return $childrenComplexity * $complexity;
            };
        }

        return $next(
            $fieldValue->setComplexity($resolver)
        );
    }
277057
public function handleField(FieldValue $value, Closure $next): FieldValue
    {
        $resolver = $value->getResolver();

        return $next(
            $value->setResolver(
                function (Model $parent, array $args, GraphQLContext $context, ResolveInfo $resolveInfo) use ($resolver): Deferred {
                    $loader = BatchLoader::instance(
                        RelationBatchLoader::class,
                        $resolveInfo->path,
                        [
                            'relationName' => $this->directiveArgValue('relation', $this->definitionNode->name->value),
                            'args' => $args,
                            'scopes' => $this->directiveArgValue('scopes', []),
                            'resolveInfo' => $resolveInfo,
                        ]
                    );

                    return new Deferred(function () use ($loader, $resolver, $parent, $args, $context, $resolveInfo) {
                        return $loader
                            ->load(
                                $parent->getKey(),
                                ['parent' => $parent]
                            )->then(
                                function () use ($resolver, $parent, $args, $context, $resolveInfo) {
                                    return $resolver($parent, $args, $context, $resolveInfo);
                                }
                            );
                    });
                }
            )
        );
    }
1233835
public function setFieldValues(array $fieldValues)
    {
        foreach ($fieldValues as $field => $fieldValue) {
            $this
                ->configuration
                ->setFieldValue(
                    $field,
                    $fieldValue
                );
        }

        return $this;
    }
1110255
public static function getInstance(FieldValue $value): self
    {
        $handler = 'query.filter'
            .'.'.strtolower($value->getParentName())
            .'.'.strtolower($value->getFieldName());

        // Get an existing instance or register a new one
        return app()->bound($handler)
            ? app($handler)
            : app()->instance($handler, app(static::class));
    }
1255373
public function handleField(FieldValue $value, Closure $next): FieldValue
    {
        $middleware = $this->getQualifiedMiddlewareNames(
            $this->directiveArgValue('checks')
        );
        $resolver = $value->getResolver();

        return $next(
            $value->setResolver(
                function ($root, array $args, GraphQLContext $context, ResolveInfo $resolveInfo) use ($resolver, $middleware) {
                    return $this->pipeline
                        ->send($context->request())
                        ->through($middleware)
                        ->then(function (Request $request) use ($resolver, $root, $args, $resolveInfo) {
                            return $resolver(
                                $root,
                                $args,
                                $this->createsContext->generate($request),
                                $resolveInfo
                            );
                        });
                }
            )
        );
    }
1236589
public function fieldValueToHash($fieldValue, array $context = array())
    {
        if ($fieldValue->uri == null) {
            return null;
        }

        return array(
            'path' => realpath($this->ioRootDir) . '/' . ($this->ioDecorator ? $this->ioDecorator->undecorate($fieldValue->uri) : $fieldValue->uri),
            'filename'=> $fieldValue->fileName,
            'mime_type' => $fieldValue->mimeType,
            'has_controller' => $fieldValue->hasController,
            'autoplay' => $fieldValue->autoplay,
            'loop'=> $fieldValue->loop,
            'width' => $fieldValue->width,
            'height' => $fieldValue->height,
        );
    }
658419
private function getterSetter($field, $fieldValue)
    {
        if ($fieldValue == null) {
            return $this->$field;
        }

        $this->$field = $fieldValue;

        return $this;
    }
770697
public function createField($fieldName, $defaultValue = null)
    {
        /** @var DateField $dateField */
        $dateField = parent::createField($fieldName, $defaultValue);

        if ($this->MinDate) {
            $dateField->setConfig('min', $this->dbObject('MinDate')->Format('Y-m-d'));
        }

        if ($this->MaxDate) {
            $dateField->setConfig('max', $this->dbObject('MaxDate')->Format('Y-m-d'));
        }

        return $dateField;
    }
453900
public function getRelationLink(string $fieldName, string $fieldValue = null): string
    {
        $tableName = Inflector::camelize(Inflector::pluralize(str_replace('_id', '', $fieldName)));

        $fieldConfig = $this->getConfig('fields.' . $fieldName);

        // reads the url defined for the given behavior (empty array if not defined)
        $fieldUrl = $this->getUrl();

        if (isset($fieldConfig['url'])) {
            // if url defined in fieldconfig. Overwrites default and behavior url config.
            $fieldUrl = $fieldConfig['url'];
        }

        unset($fieldUrl['controller']);

        $relationConfig = [
            'model' => $tableName,
            'bindingKey' => 'id',
            'url' => Hash::merge([
                'plugin' => null,
                'controller' => $tableName,
                'action' => 'view',
            ], $fieldUrl)
        ];

        $pass = [];
        if ($fieldValue !== null) {
            $pass = [$fieldValue];
        }

        try {
            $url = Router::url(Hash::merge($relationConfig['url'], $pass));
        } catch (Exception $e) {
            return $fieldValue;
        }

        return '<a href="' . $url . '" target="_blank">' . __(strtolower($tableName)) . '</a>';
    }
1358667
public function toStorageValue(FieldValue $value, StorageFieldValue $storageFieldValue)
    {
        if (isset($value->data)) {
            // Determine what needs to be stored
            if (isset($value->data['width']) && isset($value->data['fieldId'])) {
                // width + field id set means that something really needs to be stored
                $storageFieldValue->dataText = $this->createLegacyXml($value->data);
            } elseif (isset($value->data['fieldId'])) {
                // $fieldId without width mleans an empty field
                $storageFieldValue->dataText = $this->createEmptyLegacyXml($value->data);
            }
            // otherwise the image is unprocessed and the DB field stays empty
            // there will be a subsequent call to this method, after the image
            // has been stored
        }
    }
48527
public function resolve($scopeType, $scopeCode)
    {
        if (isset($this->resolvedScopeCodes[$scopeType][$scopeCode])) {
            return $this->resolvedScopeCodes[$scopeType][$scopeCode];
        }

        $resolverScopeCode = $scopeCode;

        if (($scopeCode === null || is_numeric($scopeCode))
            && $scopeType !== ScopeConfigInterface::SCOPE_TYPE_DEFAULT
        ) {
            $scopeResolver     = $this->scopeResolverPool->get($scopeType);
            $resolverScopeCode = $scopeResolver->getScope($scopeCode);
        }

        if ($resolverScopeCode instanceof \Magento\Framework\App\ScopeInterface) {
            $resolverScopeCode = $resolverScopeCode->getCode();
        }

        $this->resolvedScopeCodes[$scopeType][$scopeCode] = $resolverScopeCode;

        return $resolverScopeCode;
    }
950179
public function handleField(FieldValue $value, Closure $next): FieldValue
    {
        $this->setNodeKey(
            $value->getParent()
        );

        $value = $next($value);
        $resolver = $value->getResolver();
        $maxAge = $this->directiveArgValue('maxAge');
        $privateCache = $this->directiveArgValue('private', false);

        return $value->setResolver(function ($root, array $args, GraphQLContext $context, ResolveInfo $resolveInfo) use ($value, $resolver, $maxAge, $privateCache) {
            $cacheValue = new CacheValue([
                'field_value' => $value,
                'root' => $root,
                'args' => $args,
                'context' => $context,
                'resolve_info' => $resolveInfo,
                'private_cache' => $privateCache,
            ]);

            $cacheKey = $cacheValue->getKey();
            $cacheTags = $cacheValue->getTags();

            /** @var \Illuminate\Cache\CacheManager $cache */
            $cache = app('cache');
            $useTags = $this->useTags($cache);

            $cacheHas = $useTags
                ? $cache->tags($cacheTags)->has($cacheKey)
                : $cache->has($cacheKey);

            if ($cacheHas) {
                return $useTags
                    ? $cache->tags($cacheTags)->get($cacheKey)
                    : $cache->get($cacheKey);
            }

            $resolvedValue = $resolver($root, $args, $context, $resolveInfo);

            $cacheExp = $maxAge
                ? Carbon::now()->addSeconds($maxAge)
                : null;

            ($resolvedValue instanceof Deferred)
                ? $resolvedValue->then(function ($result) use ($cache, $cacheKey, $cacheExp, $cacheTags): void {
                    $this->store($cache, $cacheKey, $result, $cacheExp, $cacheTags);
                })
                : $this->store($cache, $cacheKey, $resolvedValue, $cacheExp, $cacheTags);

            return $resolvedValue;
        });
    }