4 ms·
GraphQL ends up being capable of whatever the backend exposes in the GraphQL schema, right - so in a way, they are isomorphic. However, in reality I'd argue Gra
by jakewins 11y ago
GraphQL ends up being capable of whatever the backend exposes in the GraphQL schema, right - so in a way, they are isomorphic. However, in reality I'd argue GraphQL is a brilliant compliment to Cypher.
Here are some use cases I think Cypher expresses nicely that I (as a GraphQL noob) don't know how to do in GraphQL:
Simple recommendation engine - suggest people with lots of friends in common that I don't already know;
MATCH (me:User)-[:KNOWS]->(friend)-[:KNOWS]->(fof)
WHERE NOT (me)-[:KNOWS]->(fof)
AND id(me) = blah
RETURN fof.name, count(friend) AS friendsInCommon
ORDER BY friendsInCommon DESC
Basic routing - what's the shortest way for me to get to work?
MATCH p = shortestPath( (home:Address)-[:ROAD*]-(work) )
WHERE home.street = .. AND work.street = ..
RETURN p
- okram 11y agoIn Gremlin3: g.V(blah).out("knows").aggregate("friends"). out("knows").where(not(within("friends"))). select(). by("name"). by(count("friends")). order().by(valueDecr)
- meowface 11y agoAs a developer who knows neither Cypher nor Gremlin, Cypher seems much more human-readable here, in my opinion. MATCH (me:User)-[:KNOWS]->(friend)-[:KNOWS]->(fof) WHERE NOT (me)-[:KNOWS]->(fof) This easily reads as "get friends (AS FOF) [who know] friends [who know] me, where me [does not know] FOF" to me. out("knows").aggregate("friends"). out("knows").where(not(within("friends"))) The Gremlin, on the other hand, reads as "get friends [who know] friends where... friend is not a friend???" to me. I also don't easily see where something should be a method and where it should be a function. Why not `order(by(valueDecr))`? Why not `select("name", count("friends"))`? Why not `where(not().within("friends"))`?
- jerven 11y agoFYI in SPARQL SELECT ?foaf WHERE { ?me a <USER> . ?me <KNOWS> ?friend . ?friend <KNOWS> ?foaf . MINUS {:me <KNOWS> ?foaf } } OR SELECT ?foaf WHERE { ?me a <USER> . ?me <KNOWS>/<KNOWS> ?foaf . MINUS {:me <KNOWS> ?foaf } }
- okram 11y agoHuh. That is a good point. In Gremlin you can chain steps together (e.g. out("knows").out("mother").out("worksFor")) and you can match patterns. So, to be clearer, I should have represented the chain as a one-liner or as a two liner with an indent. out("knows").aggregate("friends").out("knows").where(not(within("friends"))) OR out("knows").aggregate("friends"). out("knows").where(not(within("friends"))) Note the "." concatenation that ties the two lines together into a chain. When nesting parallel traversals (e.g. match()), the traversal patterns are delineated by ",". . = AND , = OR Ha. Thats a generally neat way to think of "." and "," in computing. mult and + ...the algebra.