Class InMemoryPersistedQueryCache
- java.lang.Object
-
- graphql.execution.preparsed.persisted.InMemoryPersistedQueryCache
-
- All Implemented Interfaces:
PersistedQueryCache
@PublicApi public class InMemoryPersistedQueryCache extends java.lang.Object implements PersistedQueryCache
A PersistedQueryCache that is just an in memory map of known queries.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
InMemoryPersistedQueryCache.Builder
-
Constructor Summary
Constructors Constructor Description InMemoryPersistedQueryCache(java.util.Map<java.lang.Object,java.lang.String> knownQueries)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method 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()
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface graphql.execution.preparsed.persisted.PersistedQueryCache
getPersistedQueryDocumentAsync
-
-
-
-
Method Detail
-
getKnownQueries
public java.util.Map<java.lang.Object,java.lang.String> getKnownQueries()
-
getPersistedQueryDocument
public PreparsedDocumentEntry getPersistedQueryDocument(java.lang.Object persistedQueryId, ExecutionInput executionInput, PersistedQueryCacheMiss onCacheMiss) throws PersistedQueryNotFound
Description copied from interface:PersistedQueryCache
This is called to get a persisted query from cache.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 it's 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 PreparsedDocumentEntry will be passed back ready for you to cache it.
If it's not a valid query id then throw a
PersistedQueryNotFound
to indicate this.- Specified by:
getPersistedQueryDocument
in interfacePersistedQueryCache
- Parameters:
persistedQueryId
- the persisted query idexecutionInput
- the original execution inputonCacheMiss
- the call back should it be a valid query id but it's not currently in the cache- Returns:
- a parsed and validated PreparsedDocumentEntry where
PreparsedDocumentEntry.getDocument()
is set - Throws:
PersistedQueryNotFound
- if the query id is not know at all and you have no query text
-
newInMemoryPersistedQueryCache
public static InMemoryPersistedQueryCache.Builder newInMemoryPersistedQueryCache()
-
-