Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
05-14-2019 01:30 PM
I'm hosting a neo4j database on an AWS EC2 instance. The following is an example of a resolver that I was making for finding the city that a logged in user is an expert in. I'm sure this is the ultimate newbie question, but I wasn't able to frame it well enough to find any answers. I want to know how to structure the return statement in my resolver to be able to get back the name of the city that the user is expert in.
frontend
ListUserExpertCity(cognitoId: $cognitoId) {
name
}
API Lambda Query resolver
Query: {
ListUserExpertCity:(root, args, context) => {
let session = driver.session();
let params = {cognitoId: args.cognitoId};
let query = `
MATCH (user:User { cognitoId: $cognitoId })
MATCH (city:City)
MATCH (user)-[r:EXPERT_IN]->(city)
RETURN city
;`
return session.run(query, params)
.then(
result => {
return result.records.map(record => {
console.log('record inside ListUserExpertCity',record,'record.get ',record.get("city"),'record.get with properties',record.get("city").properties)
return record.get("city").properties.name
})
}
)
}
}
I am getting the proper result in my CloudWatch logs (output of console.logs shown below), but on the frontend I am getting a null response in the following form.
ListUserExpertCity: {name: null, __typename: "City"}
I had a similar issue with a mutation that I was running, where it is properly running the mutation, but I haven't figured out the return statement.
2019-05-14T20:16:33.384Z 968e00fa-5cce-4867-b440-0cfdc6a7d911 record inside ListUserExpertCity Record {
keys: [ 'city' ],
length: 1,
_fields:
[ Node { identity: [Object], labels: [Array], properties: [Object] } ],
_fieldLookup: { city: 0 } } record.get Node {
identity: Integer { low: 222, high: 0 },
labels: [ 'City' ],
properties: { name: 'Seattle, WA' } }
record.get with properties { name: 'Seattle, WA' }
All the sessions of the conference are now available online