Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
07-17-2019 07:16 AM
apollo-server-lambda & neo4j-driver
I'm doing a query where I find out the users that someone is following. The console.log of 'collectedNames' in the backend shows the array of 4 users that they are following and all the correct properties. Somehow with the resolve I end up on the frontend with a repeat list of the same user 4 times. Any thoughts on why that could be and/or how I could improve this type of query
ListUsersFollowing: (root, args, context) => {
return new Promise((resolve, reject) => {
let session = driver.session();
let params = { cognitoId: args.cognitoId };
let query = `
MATCH (currentUser:User { cognitoId: $cognitoId }) - [:FOLLOWING] -> (users:User)
RETURN users
;`;
return (
session
.run(query, params)
.then(function(result) {
if (result.records.length < 1) {
return resolve(null);
}
let collectedNames = []; // How you return/resolve with an array
result.records.map(record => {
console.log(
"properties of the record",
record,
record.get("users").properties
);
let user = record.get("users").properties;
collectedNames.push(user);
});
console.log(
"collected names LIST USERS FOLLOWING",
collectedNames
);
return resolve(collectedNames);
})
.catch(error => {
reject(error);
})
);
});
}
01-07-2020 10:54 AM
Did you get this figured out? What exactly is being returned from the query? It might be necessary to map through the return object to get all of the returned users.
All the sessions of the conference are now available online