Enable Automatic Persisted Queries (APQ)
masterAutomatic Persisted Queries (APQ) are supported starting from version 6.1.0. APQ reduces bandwidth by sending a hash of the query instead of the full string.
To enable APQ, set EnableAutomaticPersistedQueries to true in GraphQLHttpClientOptions.
Behavior:
- If the server returns a
PersistedQueryNotSupportederror or a 400/600 HTTP status code, the client automatically disables APQ for the current session. - To re-enable APQ after it has been disabled, you must dispose of and recreate the
GraphQLHttpClient. - Optimization Tip: Use the
GraphQLQueryclass instead of raw strings inGraphQLRequest. When usingGraphQLQuery, the hash is computed once during construction, which is more efficient for reusing queries.
// Configuration
var options = new GraphQLHttpClientOptions {
EnableAutomaticPersistedQueries = true
};
// Optimized usage with GraphQLQuery
GraphQLQuery query = new("query PersonAndFilms($id: ID) { ... }");
var graphQLResponse = await graphQLClient.SendQueryAsync<ResponseType>(
query,
"PersonAndFilms",
new { id = "cGVvcGxlOjE=" });