@PublicApi public class InMemoryPersistedQueryCache extends java.lang.Object implements PersistedQueryCache
Modifier and Type | Class and Description |
---|---|
static class |
InMemoryPersistedQueryCache.Builder |
Constructor and Description |
---|
InMemoryPersistedQueryCache(java.util.Map<java.lang.Object,java.lang.String> knownQueries) |
Modifier and Type | Method and Description |
---|---|
java.util.Map<java.lang.Object,java.lang.String> |
getKnownQueries() |
PreparsedDocumentEntry |
getPersistedQueryDocument(java.lang.Object persistedQueryId,
ExecutionInput executionInput,
PersistedQueryCacheMiss onCacheMiss)
This is called to get a persisted query from cache.
|
static InMemoryPersistedQueryCache.Builder |
newInMemoryPersistedQueryCache() |
public InMemoryPersistedQueryCache(java.util.Map<java.lang.Object,java.lang.String> knownQueries)
public java.util.Map<java.lang.Object,java.lang.String> getKnownQueries()
public PreparsedDocumentEntry getPersistedQueryDocument(java.lang.Object persistedQueryId, ExecutionInput executionInput, PersistedQueryCacheMiss onCacheMiss) throws PersistedQueryNotFound
PersistedQueryCache
If its present in cache then it must return a PreparsedDocumentEntry where PreparsedDocumentEntry.getDocument()
is already parsed and validated. This will be passed onto the graphql engine as is.
If its a valid query id but its no present in cache, (cache miss) then you need to call back the "onCacheMiss" function with associated query text. This will be compiled and validated by the graphql engine and the a PreparsedDocumentEntry will be passed back ready for you to cache it.
If its not a valid query id then throw a PersistedQueryNotFound
to indicate this.
getPersistedQueryDocument
in interface PersistedQueryCache
persistedQueryId
- the persisted query idexecutionInput
- the original execution inputonCacheMiss
- the call back should it be a valid query id but its not currently not in the cachePreparsedDocumentEntry.getDocument()
is setPersistedQueryNotFound
- if the query id is not know at all and you have no query textpublic static InMemoryPersistedQueryCache.Builder newInMemoryPersistedQueryCache()