hiku.result

In all examples query results are showed in denormalized form, suitable for reading (by humans) and for serializing into simple formats, into JSON for example. But this is not how Hiku stores result internally.

Internally Hiku stores result in a fully normalized form. So result in Hiku is also a graph structure with references between objects. This approach has lots of advantages:

  • normalization helps to heavily reduce size of serialized result when we need to transfer it (this avoids data duplication)

  • it reduces internal memory usage and simplifies work with data internally

  • gives ability to cache, precisely and effortlessly update local state on the client

hiku.result.denormalize(graph: Graph, result: Proxy) Dict

Transforms normalized result (graph) into simple hierarchical structure

This hierarchical structure will follow query structure.

Note

To work properly this function requires that incoming query was merged by using hiku.query.merge() function. This is done by default in all query readers.

Example:

query = hiku.readers.graphql.read('{ foo }')
norm_result = hiku_engine.execute(graph, query)
result = hiku.result.denormalize(graph, norm_result)
assert result == {'foo': 'value'}
Parameters:
  • graphGraph definition

  • result – result of the query