public static function instance(string $loaderClass, array $pathToField, array $constructorArgs = []): self
    {
        // The path to the field serves as the unique key for the instance
        $instanceName = static::instanceKey($pathToField);

        // If we are resolving a batched query, we need to assign each
        // query a uniquely indexed instance
        /** @var \Nuwave\Lighthouse\Execution\GraphQLRequest $graphQLRequest */
        $graphQLRequest = app(GraphQLRequest::class);
        if ($graphQLRequest->isBatched()) {
            $currentBatchIndex = $graphQLRequest->batchIndex();
            $instanceName = "batch_{$currentBatchIndex}_{$instanceName}";
        }

        // Only register a new instance if it is not already bound
        $instance = app()->bound($instanceName)
            ? app($instanceName)
            : app()->instance(
                $instanceName,
                app()->makeWith($loaderClass, $constructorArgs)
            );

        if (! $instance instanceof self) {
            throw new Exception(
                "The given class '$loaderClass' must resolve to an instance of Nuwave\Lighthouse\Execution\DataLoader\BatchLoader"
            );
        }

        return $instance;
    }