cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Custom `asFunction` returns a column-value map instead of just the node

peey
Node Clone

I have a custom function defined like:

CALL apoc.custom.asFunction('fn', "MATCH ...
    RETURN stuff", 'NODE', [['param1', 'STRING']], false, 'docstring')

It's supposed to return a matched node by some criteria. When I run CALL custom.fn("something") The returned result I'm seeing is

{
  "stuff": {
"identity": 1,
"labels": [
      "Target"
    ],
"properties": {
"value": 2
    }
  }
}

but I can't seem to get rid of that extra level of nesting "stuff" and just get

{
"identity": 1,
"labels": [
      "Target"
    ],
"properties": {
"value": 2
    }
  }

How could I get rid of it? It's really a nuisance when trying to use custom function e.g.

WITH custom.fn("something") as x
MATCH (x)-[r]->(y)
RETURN x, r, y

I get the error

Expected to find a node at 'x' but found Map{stuff -> (1)} instead

and I have to do tricky thing to lookup by x.stuff instead. I just want return value directly to be the node.

1 REPLY 1

peey
Node Clone

I believe this is a bug. There's even more weirdness surrounding this issue. Reported here: https://github.com/neo4j-contrib/neo4j-apoc-procedures/issues/1714 with steps / full statements to reproduce