graphql.execution.preparsed.persisted.PersistedQuerySupport Maven / Gradle / Ivy
package graphql.execution.preparsed.persisted;
import graphql.ExecutionInput;
import graphql.GraphQLError;
import graphql.GraphqlErrorBuilder;
import graphql.PublicSpi;
import graphql.execution.preparsed.PreparsedDocumentEntry;
import graphql.execution.preparsed.PreparsedDocumentProvider;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import java.util.function.Function;
import static graphql.Assert.assertNotNull;
import static java.util.concurrent.CompletableFuture.completedFuture;
/**
* 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
* a {@link PersistedQueryCache} implementation.
*
* @see graphql.execution.preparsed.PreparsedDocumentProvider
* @see graphql.GraphQL.Builder#preparsedDocumentProvider(graphql.execution.preparsed.PreparsedDocumentProvider)
*/
@PublicSpi
public abstract class PersistedQuerySupport implements PreparsedDocumentProvider {
/**
* In order for {@link graphql.ExecutionInput#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
*/
public static final String PERSISTED_QUERY_MARKER = "PersistedQueryMarker";
private final PersistedQueryCache persistedQueryCache;
public PersistedQuerySupport(PersistedQueryCache persistedQueryCache) {
this.persistedQueryCache = assertNotNull(persistedQueryCache);
}
@Override
public CompletableFuture getDocumentAsync(ExecutionInput executionInput, Function parseAndValidateFunction) {
Optional
© 2015 - 2024 Weber Informatics LLC | Privacy Policy