Changes in 0.2#

0.2.0#

  • Added ability to export hiku.query nodes. Added hiku.export.simple exporter, which will export query into EDN data structure

  • Added debug mode for the hiku.console application, showing Python tracebacks if debug mode is turned on

  • Implemented hiku.validate.query.QueryValidator to validate query against graph definition before it’s execution

  • Implemented hiku.validate.graph.GraphValidator to validate graph definition

  • Added ability to define graph links with hiku.types.Optional type:

    Link('link-to-foo', Optional[TypeRef['foo']], func, requires=None)
    
  • Added ability to query complex fields, which has a type of Optional[Record[...]], Record[...] or Sequence[Record[...]] as if they were linked edges:

    Edge('foo', [
        Field('bar', Record[{'baz': Integer}], func),
    ])
    

    Here bar field should be queried as it was a link to the edge:

    [{:link-to-foo [{:bar [:baz]}]}]
    
  • Added ability to use scalar values in the expressions. Currently only integer numbers and strings are supported:

    Expr('foo', foo_subgraph, func(S.this.foo, 'scalar'))
    
  • Implemented hiku.expr.if_some() function in order to unpack hiku.types.Optional type in expressions

  • Added ability to pass objects, required to execute query, using bound to the query context:

    @pass_context
    def func(ctx, fields):
        return [ctx['storage'][f.name] for f in fields]
    
    Root([
        Field('foo', None, func),
    ])
    
    engine.execute(graph, read('[:foo]'),
                   ctx={'storage': {'foo': 1}})
    
  • Implemented new hiku.sources.aiopg source for using aiopg and hiku.executors.asyncio.AsyncIOExecutor to asynchronously load data from the PostgreSQL database

  • Added ability to define function arguments using types instead of queries:

    @define(Record[{'foo': Integer}])  # instead of @define('[[:foo]]')
    def func(arg):
        return arg['foo'] + 1
    

Backward-incompatible changes#

  • Changed type of hiku.graph.Field.options from Mapping[str, Option] to Sequence[Option]

  • Changed type of hiku.graph.Link.options from Mapping[str, Option] to Sequence[Option]

  • Changed type of hiku.graph.Edge.fields from Mapping[str, Union[Field, Link]] to Sequence[Union[Field, Link]]

  • Changed type of hiku.query.Edge.fields from Mapping[str, Union[Field, Link]] to Sequence[Union[Field, Link]]

  • hiku.graph.Graph is not a subclass of the hiku.graph.Edge anymore, all the root edges, fields and links should be defined in the hiku.graph.Root edge. Now hiku.graph.Graph can contain only edges

  • All hiku.types and hiku.typedef.types are now subclasses of type, instead of being instances of type

  • Renamed hiku.types.Type into hiku.types.GenericMeta

  • Renamed hiku.types.BooleanType into hiku.types.Boolean

  • Renamed hiku.types.StringType into hiku.types.String

  • Renamed hiku.types.IntegerType into hiku.types.Integer

  • Renamed hiku.types.OptionType into hiku.types.Optional

  • Renamed hiku.types.ListType into hiku.types.Sequence

  • Renamed hiku.types.DictType into hiku.types.Mapping

  • Renamed hiku.types.RecordType into hiku.types.Record

  • Renamed hiku.types.FunctionType into hiku.types.Callable

  • Removed hiku.types.ContainerType

  • Removed hiku.types.to_instance()

  • Moved hiku.typedef.types.TypeRef into hiku.types.TypeRef

  • Moved hiku.typedef.types.TypeRefMeta into hiku.types.TypeRefMeta

  • Replaced required keyword arguments to_list and edge in the hiku.graph.Link class by one second positional argument, which can have one of these values:

    • TypeRef['foo'] or Optional[TypeRef['foo']] instead of edge='foo', to_list=False

    • Sequence[TypeRef['foo']] instead of edge='foo', to_list=True

    Before:

    Link('foo', func, edge='bar', requires='id', to_list=True)
    

    Now:

    Link('foo', Sequence[TypeRef['bar']], func, requires='id')
    
  • Replaced required keyword arguments to_list and edge in the hiku.sources.sqlalchemy.LinkQuery class by one second positional argument, as in hiku.graph.Link

  • Renamed required keyword argument and corresponding instance attribute from doc into description in the hiku.graph.Field, hiku.graph.Link, hiku.graph.Edge and in the hiku.sources.sqlalchemy.Link classes

  • Renamed attribute of the hiku.typedef.kinko.TypeDoc from __type_doc__ into __type_description__

  • Moved constant hiku.engine.Nothing to the hiku.graph.Nothing

  • Renamed attribute hiku.result.Ref.storage into hiku.result.Ref.index

  • Renamed attribute hiku.result.State.idx into hiku.result.State.index

  • hiku.sources.sqlalchemy.FieldsQuery and hiku.sources.sqlalchemy.LinkQuery now require context keys instead of “connectable” objects (SQLAlchemy’s scoped session)

  • Moved type hiku.typedef.types.Unknown to the hiku.types.Unknown

  • Positional type argument in hiku.graph.Field and in hiku.graph.Option now is required