Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible to retain Node association when returning a subset of properties? #129

Closed
brian-gates opened this issue Sep 1, 2016 · 4 comments

Comments

@brian-gates
Copy link
Contributor

match (n) return n

The above returns Node objects.

match (n) return { id: n.id } as n

Does not.

Is it possible to retain the association while also minimizing the return payload?

@pontusmelke
Copy link
Contributor

I am not sure I completely follow, if you don't need a full node object you should just return the things you need,

MATCH (n) RETURN id(n), n.prop1, n.prop2,...

or am I missing your point?

@brian-gates
Copy link
Contributor Author

brian-gates commented Sep 6, 2016

I've essentially done this. Here is my implementation:

return { __isNode: true, id: id(n), labels: labels(n), properties: { id: n.id, name: n.name } } as n

This works, but is quite a bit of extra work to re-implement the functionality one gets for free via a bonafide Node object. And I still have to manually reinstate the item's Nodeness based on what is returned.

I understand why a Node isn't returned. It's a hash. Who knows what's in it?

Perhaps map projections resolves this?

https://neo4j.com/blog/cypher-graphql-neo4j-3-1-preview/

@pontusmelke
Copy link
Contributor

Ok, now I understand what you mean. No currently there is no magic way of achieving this, we are working on better ways of serializing graph properties both on the server side and in the drivers. Map projections is one of these endeavors that might work for you but you will unfortunately have to wait for 3.1 for that one.

Regards,
Pontus

@brian-gates
Copy link
Contributor Author

Yeah I figured. I'm guessing map projections won't even solve the issue, since I assume they return maps (given the name).

I think what we need is some way to "mask" the output. It sounds like a separate feature to map projections.

Anyway, I'll close the issue, especially since it sounds like it has nothing to do with this driver specifically.

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

No branches or pull requests

2 participants