Skip to content

Commit 8fc2b53

Browse files
Autofix
1 parent 707f257 commit 8fc2b53

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

docs/executing-queries.md

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -210,16 +210,17 @@ $server = new StandardServer([
210210
'validationRules' => $myValidationRules
211211
]);
212212
```
213+
213214
## Validation Caching
214215

215-
Validation is a required step in GraphQL execution, but it can become a performance bottleneck when the same queries are
216-
run repeatedly — especially in production environments where queries are often static or pre-generated (e.g., persisted
216+
Validation is a required step in GraphQL execution, but it can become a performance bottleneck when the same queries are
217+
run repeatedly — especially in production environments where queries are often static or pre-generated (e.g., persisted
217218
queries or queries emitted by client libraries).
218219

219-
To optimize for this, graphql-php supports pluggable validation caching. By implementing the GraphQL\Validator\ValidationCache
220+
To optimize for this, graphql-php supports pluggable validation caching. By implementing the GraphQL\Validator\ValidationCache
220221
interface and passing it to GraphQL::executeQuery(), you can skip validation for queries already known to be valid:
221222

222-
To optimize for this, `graphql-php` supports pluggable validation caching. By implementing the `GraphQL\Validator\ValidationCache` interface and passing it to
223+
To optimize for this, `graphql-php` supports pluggable validation caching. By implementing the `GraphQL\Validator\ValidationCache` interface and passing it to
223224
`GraphQL::executeQuery()`, you can skip validation for queries that are already known to be valid.
224225

225226
```php
@@ -243,15 +244,17 @@ $result = GraphQL::executeQuery(
243244
```
244245

245246
### Key Generation Tips
247+
246248
You are responsible for generating your own cache keys in a way that uniquely identifies the schema, the query, and
247249
(optionally) any custom validation rules. Here are some tips:
248250

249-
* Hash your schema once at build time and store the result in an environment variable or constant.
250-
* Avoid using serialize() on schema objects — closures and internal references may cause errors.
251-
* If using custom validation rules, be sure to account for them in your key (e.g., by serializing or listing their class names).
252-
* Consider including the graphql-php version number to account for internal rule changes across versions.
251+
- Hash your schema once at build time and store the result in an environment variable or constant.
252+
- Avoid using serialize() on schema objects — closures and internal references may cause errors.
253+
- If using custom validation rules, be sure to account for them in your key (e.g., by serializing or listing their class names).
254+
- Consider including the graphql-php version number to account for internal rule changes across versions.
253255

254256
### Sample Implementation
257+
255258
```php
256259
use GraphQL\Validator\ValidationCache;
257260
use GraphQL\Language\AST\DocumentNode;
@@ -262,7 +265,7 @@ use Composer\InstalledVersions;
262265

263266
/**
264267
* Reference implementation of ValidationCache using PSR-16 cache.
265-
*
268+
*
266269
* @see GraphQl\Tests\PsrValidationCacheAdapter
267270
*/
268271
class PsrValidationCacheAdapter implements ValidationCache
@@ -303,8 +306,8 @@ class PsrValidationCacheAdapter implements ValidationCache
303306

304307
// Include graphql-php version to account for internal changes
305308
$libraryVersion = \Composer\InstalledVersions::getVersion('webonyx/graphql-php') ?: 'unknown';
306-
309+
307310
return "graphql_validation_{$libraryVersion}_{$schemaHash}_{$astHash}_{$rulesHash}";
308311
}
309312
}
310-
```
313+
```

0 commit comments

Comments
 (0)