arcadedb icon indicating copy to clipboard operation
arcadedb copied to clipboard

HTTP/JSON POST query with `serializer` as `graph` returns empty edges array

Open jymcheong opened this issue 11 months ago • 3 comments

ArcadeDB Version:

Docker image 24.11.2

OS and JDK Version:

Container

Expected behavior

return both non-empty vertices & edges arrays

Actual behavior

vertices populated but edges array empty

  • tested with both curl & low code platform rest call
  • arcadeDB web UI however shows correct vertices + edges + records

Steps to reproduce

create a test DB, use the following

sqlscript

CREATE VERTEX TYPE  Alert IF NOT EXISTS;
CREATE VERTEX TYPE Asset IF NOT EXISTS;
INSERT into Alert content {description:'some alert'};
INSERT into Asset content {description:'some asset'};

cypher to quickly create edge between the 2 records

MATCH (a:Alert),(b:Asset)
CREATE (a)-[r:ASSOCIATEDWITH]->(b)

query, but change RID

traverse both() from #25:0

terminal curl, change to your db name & root pass

curl -X POST http://localhost:2480/api/v1/query/test2  -d '{ "language": "sql", "command": "traverse both() from #25:0", "serializer":"graph"}' -H "Content-Type: application/json" --user root:whatever

my output from terminal as well as low code REST client, towards the end, edges is empty array

{"user":"root","version":"24.11.2 (build 055592c73d27d894c26f3faaf7df22e15c28f03d/1733838604617/main)","serverName":"ArcadeDB_0","result":{"vertices":[{"p":{"description":"some alert","@cat":"v","@type":"Alert","@rid":"#25:0"},"r":"#25:0","t":"Alert","i":0,"o":1},{"p":{"description":"some asset","@cat":"v","@type":"Asset","@rid":"#1:0"},"r":"#1:0","t":"Asset","i":1,"o":0}],"edges":[]}}

I understand that vertices array contains i and o that are using array index format & it is possible to workaround to "rebuild" edges array, but this is somewhat inconsistent.

The edges array contain edge name that cannot be inferred from vertices array, so it is a problem when we build our custom low code web UI.

How does the arcadeDB webUI fetches both graph & records at one go, is it using the same HTTP/JSON Api or something different? Cos the output from arcadeDB JSON tab however shows BOTH graph & record

{
  "user": "root",
  "version": "24.11.2 (build 055592c73d27d894c26f3faaf7df22e15c28f03d/1733838604617/main)",
  "serverName": "ArcadeDB_0",
  "result": {
    "vertices": [
      {
        "p": {
          "description": "some alert",
          "@cat": "v",
          "@type": "Alert",
          "@rid": "#25:0"
        },
        "r": "#25:0",
        "t": "Alert",
        "i": 0,
        "o": 1
      },
      {
        "p": {
          "description": "some asset",
          "@cat": "v",
          "@type": "Asset",
          "@rid": "#1:0"
        },
        "r": "#1:0",
        "t": "Asset",
        "i": 1,
        "o": 0
      }
    ],
    "edges": [
      {
        "p": {
          "@cat": "e",
          "@type": "ASSOCIATEDWITH",
          "@rid": "#49:0",
          "@in": "#1:0",
          "@out": "#25:0"
        },
        "r": "#49:0",
        "t": "ASSOCIATEDWITH",
        "i": "#1:0",
        "o": "#25:0"
      },
      {
        "p": {
          "@cat": "e",
          "@type": "ASSOCIATEDWITH",
          "@rid": "#49:0",
          "@in": "#1:0",
          "@out": "#25:0"
        },
        "r": "#49:0",
        "t": "ASSOCIATEDWITH",
        "i": "#1:0",
        "o": "#25:0"
      }
    ],
    "records": [
      {
        "@rid": "#25:0",
        "@type": "Alert",
        "@cat": "v",
        "@out": 1,
        "@in": 0,
        "description": "some alert"
      },
      {
        "@rid": "#1:0",
        "@type": "Asset",
        "@cat": "v",
        "@out": 0,
        "@in": 1,
        "description": "some asset"
      }
    ]
  },
  "explain": "+ FETCH FROM RIDs\n  [#25:0]\n+ DEPTH-FIRST TRAVERSE \n  [both()]"
}

jymcheong avatar Jan 14 '25 09:01 jymcheong

Oh I realise I understand it wrongly, i & o refers to the edge counts, so this is a show stopper.

jymcheong avatar Jan 14 '25 10:01 jymcheong

Hi, with regard to your question how the webUI (studio) gets all the info in one request: There is a special (undocumented) serializer called studio.

Also, this issue: https://github.com/ArcadeData/arcadedb/issues/1590 may be related.

gramian avatar Jan 14 '25 10:01 gramian

@gramian Thank u sir! You saved my project!

jymcheong avatar Jan 14 '25 11:01 jymcheong