Persistent queries significantly improve the performance of an app as the smaller hash signature reduces bandwidth utilization.
extensions
key isn’t provided in the GET
request, Dgraph processes
the request as usualpersistedQuery
exists under the extensions
key, Dgraph tries to
process a Persisted Query:
sha256
hash is provided, process the query without persistingsha256
hash is provided, try to retrieve the persisted queryquery
and sha256
must be provided.
Dgraph verifies the hash and performs a lookup. If the query doesn’t exist,
Dgraph stores the query, provided that the sha256
of the query is correct.
Finally, Dgraph processes the query and returns the results.
Example:
sha256
is provided, Dgraph does a look-up, and processes the query
if found. Otherwise a PersistedQueryNotFound
error is returned.
Example: curl -g
‘http://localhost:8080/graphql/?extensions={“persistedQuery”:{“sha256Hash”:“b952c19b894e1aa89dc05b7d53e15ab34ee0b3a3f11cdf3486acef4f0fe85c52”}}‘