Weâre overhauling Dgraphâs docs to make them clearer and more approachable. If
you notice any issues during this transition or have suggestions, please
let us know.
Persisted query logic
The execution of Persistent Queries follows this logic:- If the
extensionskey isnât provided in theGETrequest, Dgraph processes the request as usual - If a
persistedQueryexists under theextensionskey, Dgraph tries to process a Persisted Query:- if no
sha256hash is provided, process the query without persisting - if the
sha256hash is provided, try to retrieve the persisted query
- if no
Create
To create a Persistent Query, bothquery 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:
Lookup
If only asha256 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â}}â