Skip to content

Adding edge facet is not working #136

@robin-snt

Description

@robin-snt

Dgraph: v20.03.1
pydgraph: 20.3.0

First I tried using json format, which didn't work then I tried N-quads which is mutated using the following function:

def set_facet(client, src_uid, trg_uid, predicate, facets):
    '''Set edge facets

    :param client: dgraph client object
    :param src_uid: dgraph source node UID
    :type src_uid: str
    :param trg_uid: dgraph source node UID
    :type trg_uid: str
    :param predicate: dgraph edge predicate
    :type predicate: str
    :param facets: facet key, value tuple
    :type facets: ((str, str|bool|int|float), ...)
    '''

    nquads = '\n'.join(f'<{src_uid}> <{predicate}> <{trg_uid}> '
                       f'({k}={json.dumps(v)}) .' for k, v in facets)

    print('FACET:', nquads)
    txn = client.txn()

    try:
        txn.mutate(set_nquads=nquads, commit_now=True)
    finally:
        txn.discard()

I execute my python script and verify that the nquad is logged to stdout:
FACET: <0x13a4a> <result> <0x13a24> (cached=true) .

.. and inspect the graph:

Screenshot from 2020-05-29 16-54-43

Screenshot from 2020-05-29 16-57-55

No facets to be seen, and I know the function executed. When I copy-paste the n-quad from stdout and execute a mutation query in ratel:

{
  set {
    <0x13a4a> <result> <0x13a24> (cached=true) .
  }
}

, the graph is mutated:

Screenshot from 2020-05-29 17-03-01

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions