Skip to content

Commit a2c38f4

Browse files
committed
stanning
1 parent c3a7eb4 commit a2c38f4

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/Validator/DocumentValidator.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
use GraphQL\Validator\Rules\VariablesAreInputTypes;
5151
use GraphQL\Validator\Rules\VariablesInAllowedPosition;
5252
use Psr\SimpleCache\CacheInterface;
53+
use Psr\SimpleCache\InvalidArgumentException;
5354

5455
/**
5556
* Implements the "Validation" section of the spec.
@@ -108,9 +109,11 @@ public static function validate(
108109
if (isset($cache)) {
109110
$cacheKey = 'gql_validation_' . md5($ast->__toString());
110111

111-
if ($cache->has($cacheKey)) {
112-
return $cache->get($cacheKey);
113-
}
112+
try {
113+
if ($cache->has($cacheKey)) {
114+
return $cache->get($cacheKey);
115+
}
116+
} catch (InvalidArgumentException $e) {}
114117
}
115118

116119
$rules ??= static::allRules();
@@ -137,9 +140,11 @@ public static function validate(
137140
$errors = $context->getErrors();
138141

139142
// Only cache clean results
140-
if ($cache && $cacheKey && count($errors) === 0) {
141-
$cache->set($cacheKey, $errors);
142-
}
143+
try {
144+
if (isset($cacheKey) && count($errors) === 0) {
145+
$cache->set($cacheKey, $errors);
146+
}
147+
} catch (InvalidArgumentException $e) {}
143148

144149
return $errors;
145150
}

0 commit comments

Comments
 (0)