Skip to content
This repository has been archived by the owner on Sep 3, 2021. It is now read-only.

How can I return both a node and its relationship in a way neo4j-graphql-js accepts? #576

Open
dan-fein opened this issue Jan 19, 2021 · 1 comment

Comments

@dan-fein
Copy link

dan-fein commented Jan 19, 2021

Hi I have been stuck on this for a few days now. This tends to work in the Desktop Browser but not neo4j-graphql-js. So I'm hoping you can help.

I have this MATCH:

OPTIONAL MATCH (this)-[r:FOLLOWS]->(something)-[WROTE|TAGGED]-(post:Post)

And I would like to return all posts combined with r. I tried to use a map but it was rejected by neo4j as expecting a node. I tried to use a virtual node but that didn't seem to be supported. I can't figure out how to use this.

This is my full query currently:

OPTIONAL MATCH (this)-[r:FOLLOWS]->(something)-[r2:WROTE|TAGGED]-(post:Post)
WITH COLLECT(post) as rows
OPTIONAL MATCH (this)-[:WROTE]->(post:Post)
WITH rows + COLLECT(post) as allRows
UNWIND allRows as post
RETURN DISTINCT post
ORDER BY post.date DESC

I don't think you can just RETURN DISTINCT post, r, right? Because neo4j-graphql-js expects one single object as a response?

Thank you in advance!

@michaeldgraham
Copy link
Collaborator

#608

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants