in graphql-dgs-spring-graphql/src/main/kotlin/com/netflix/graphql/dgs/apq/AutomatedPersistedQueryCacheAdapter.kt [35:55]
override fun getPersistedQueryDocumentAsync(
persistedQueryId: Any,
executionInput: ExecutionInput,
onCacheMiss: PersistedQueryCacheMiss,
): CompletableFuture<PreparsedDocumentEntry> {
val key =
when (persistedQueryId) {
is String -> persistedQueryId
else -> persistedQueryId.toString()
}
return CompletableFuture.completedFuture(
getFromCache(key) {
// Get the query from the execution input. Make sure it's not null, empty or the APQ marker.
val queryText = executionInput.query
if (queryText.isNullOrBlank() || queryText.equals(PersistedQuerySupport.PERSISTED_QUERY_MARKER)) {
throw PersistedQueryNotFound(persistedQueryId)
}
return@getFromCache onCacheMiss.apply(queryText)
},
)
}