Caching does not take operation name into account
dulnan opened this issue · 0 comments
dulnan commented
The cachePrefix()
method in Executor.php
generates a hash based on the query, variables and extensions:
$hash = hash('sha256', serialize([
'query' => DocumentSerializer::serializeDocument($this->document),
'variables' => $variables,
'extensions' => $extensions,
]));
This only works when the document contains a single operation. If the document contains let's say two queries, it will cache the first result and subsequently resolve the cached result for any of the operations in the document. To fix it, the name of the operation should be taken into account.
Example:
query one {
currentUser {
name
}
}
query two {
nodeById(id: 12) {
title
}
}
Executing the query "one" first and then "two" will return the result from query "one".