Class PersistedQuerySupport
- java.lang.Object
-
- graphql.execution.preparsed.persisted.PersistedQuerySupport
-
- All Implemented Interfaces:
PreparsedDocumentProvider
- Direct Known Subclasses:
ApolloPersistedQuerySupport
@PublicSpi public abstract class PersistedQuerySupport extends java.lang.Object implements PreparsedDocumentProvider
This abstract class forms the basis for persistent query support. Derived classes need to implement the method to work out the query id and you also need aPersistedQueryCache
implementation.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
PERSISTED_QUERY_MARKER
In order forExecutionInput.getQuery()
to never be null, use this to mark them so that invariant can be satisfied while assuming that the persisted query id is elsewhere
-
Constructor Summary
Constructors Constructor Description PersistedQuerySupport(PersistedQueryCache persistedQueryCache)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description PreparsedDocumentEntry
getDocument(ExecutionInput executionInput, java.util.function.Function<ExecutionInput,PreparsedDocumentEntry> parseAndValidateFunction)
This is called to get a "cached" pre-parsed query and if it's not present, then the "parseAndValidateFunction" can be called to parse and validate the query.protected abstract java.util.Optional<java.lang.Object>
getPersistedQueryId(ExecutionInput executionInput)
This method is required for concrete types to work out the query id (often a hash) that should be used to look up the persisted query in the cache.protected PreparsedDocumentEntry
mkMissingError(PersistedQueryError persistedQueryError)
Allows you to customize the graphql error that is sent back on a missing persisted queryprotected boolean
persistedQueryIdIsInvalid(java.lang.Object persistedQueryId, java.lang.String queryText)
-
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.PreparsedDocumentProvider
getDocumentAsync
-
-
-
-
Field Detail
-
PERSISTED_QUERY_MARKER
public static final java.lang.String PERSISTED_QUERY_MARKER
In order forExecutionInput.getQuery()
to never be null, use this to mark them so that invariant can be satisfied while assuming that the persisted query id is elsewhere- See Also:
- Constant Field Values
-
-
Constructor Detail
-
PersistedQuerySupport
public PersistedQuerySupport(PersistedQueryCache persistedQueryCache)
-
-
Method Detail
-
getDocument
public PreparsedDocumentEntry getDocument(ExecutionInput executionInput, java.util.function.Function<ExecutionInput,PreparsedDocumentEntry> parseAndValidateFunction)
Description copied from interface:PreparsedDocumentProvider
This is called to get a "cached" pre-parsed query and if it's not present, then the "parseAndValidateFunction" can be called to parse and validate the query.Note - the "parseAndValidateFunction" MUST be called if you don't have a per parsed version of the query because it not only parses and validates the query, it invokes
Instrumentation
calls as well for parsing and validation. if you don't make a call back on this then these wont happen.- Specified by:
getDocument
in interfacePreparsedDocumentProvider
- Parameters:
executionInput
- TheExecutionInput
containing the queryparseAndValidateFunction
- If the query has not be pre-parsed, this function MUST be called to parse and validate it- Returns:
- an instance of
PreparsedDocumentEntry
-
getPersistedQueryId
protected abstract java.util.Optional<java.lang.Object> getPersistedQueryId(ExecutionInput executionInput)
This method is required for concrete types to work out the query id (often a hash) that should be used to look up the persisted query in the cache.- Parameters:
executionInput
- the execution input- Returns:
- an optional id of the persisted query
-
persistedQueryIdIsInvalid
protected boolean persistedQueryIdIsInvalid(java.lang.Object persistedQueryId, java.lang.String queryText)
-
mkMissingError
protected PreparsedDocumentEntry mkMissingError(PersistedQueryError persistedQueryError)
Allows you to customize the graphql error that is sent back on a missing persisted query- Parameters:
persistedQueryError
- the missing persistent query exception- Returns:
- a PreparsedDocumentEntry that holds an error
-
-