Ok ... therefore, to get what I wanted to represent both node and the edge relation to graphql, I did what I would call work-around, returning object.assign (node, relation) to graphql .... the disadvantage is that I have to define the type nodeRel {} to get combined objects, but it works. In addition, node objects and relationships cannot have similar named properties. Now I can answer the question of how long John and Mary have been friends or groups to which John belongs and how long he has been a member ... Schema snippet:
... memberOf : [Group] groupStatus : [MemberProfile] attended : [Meeting] submittedReport : [Report] post : [Post] } type MemberProfile { name : String location : String created : String since : String role : String financial : Boolean active : Boolean }
Resolver:
groupStatus(voter) { let session = driver.session(), params = { voterid: voter.voterid }, query = ` MATCH (v:Voter)-[r:MEMBER_OF]->(g:Group) WHERE v.voterid = $voterid RETURN g AS group,r AS rel; ` return session .run(query, params) .then(result => { return result.records.map(record => { return Object.assign(record.get("group").properties, record.get("rel").properties) }) }) },
Hope this helps someone else ...
MichaelE
source share