Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/Context/Context.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@

namespace TheCodingMachine\GraphQLite\Context;

use SplObjectStorage;
use TheCodingMachine\GraphQLite\Parameters\ParameterInterface;
use TheCodingMachine\GraphQLite\PrefetchBuffer;
use WeakMap;

/**
* A context class that should be passed to the Webonyx executor.
*/
class Context implements ContextInterface, ResetableContextInterface
{
private SplObjectStorage $prefetchBuffers;
private WeakMap $prefetchBuffers;

public function __construct()
{
$this->prefetchBuffers = new SplObjectStorage();
$this->prefetchBuffers = new WeakMap();
}

/**
Expand All @@ -38,6 +38,6 @@ public function getPrefetchBuffer(ParameterInterface $field): PrefetchBuffer

public function reset(): void
{
$this->prefetchBuffers = new SplObjectStorage();
$this->prefetchBuffers = new WeakMap();
}
}
8 changes: 4 additions & 4 deletions src/PrefetchBuffer.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace TheCodingMachine\GraphQLite;

use GraphQL\Type\Definition\ResolveInfo;
use SplObjectStorage;
use WeakMap;

use function md5;
use function serialize;
Expand All @@ -18,12 +18,12 @@ class PrefetchBuffer
/** @var array<string, array<int, object>> An array of buffered, indexed by hash of arguments. */
private array $objects = [];

/** @var SplObjectStorage A Storage of prefetch method results, holds source to resolved values. */
private SplObjectStorage $results;
/** @var WeakMap A Storage of prefetch method results, holds source to resolved values. */
private WeakMap $results;

public function __construct()
{
$this->results = new SplObjectStorage();
$this->results = new WeakMap();
}

/** @param array<array-key, mixed> $arguments The input arguments passed from GraphQL to the field. */
Expand Down
Loading