4 ms·
A query on a graph or a tree can both be RESTful. You can describe traversals of the graph or tree in a query embedded in an HTTP endpoint. You don't need to ma
by eggie 11y ago
A query on a graph or a tree can both be RESTful. You can describe traversals of the graph or tree in a query embedded in an HTTP endpoint. You don't need to make repeated round trip queries to do the traversal unless you are unwilling to use a suitable query description.
Metaphorically this is all pretty funny becuase the web is already a graph at a fundamental level.
- neilellis 11y agoLOL, yes that is a very good point. And how does the web solve this, by reference :-) Which is of course how you always solve cyclical graph representations in my (for sure limited) experience.
- dustingetz 11y agoThe problem is that traversing a HATEOAS graph (like the www) requires a request at each edge. (The query is only the entry point to the graph, it doesn't help you traverse the graph. Relational joins make it so you don't need to traverse the graph, but this requires a lot of custom endpoints that bake in up-front knowledge about which nodes of the graph will need to be pre-fetched) edit: Either you edited or I misread, but "You can describe traversals of the graph or tree in a query embedded in an HTTP endpoint" - this is basically what GraphQL/Relay is: an easy way to do arbitrarily nested or recursive queries, like those you find in real complex applications. (Plug: I am a React consultant, hire me!)
- lumpypua 11y agoHaha your edit is dead on. Your parent comment arguing for REST just reinvented GraphQL.
- eggie 11y agoAs someone with a bit more experience with these technologies, would you please describe what GraphQL actually has to do with graphs? I work with very, very large graphs. I looked at GraphQL to see if it could be of use, but as far as I can understand the graph aspect of GraphQL is marketing multiplied by doublespeak. RDF and Sparql seem to be much more apt systems in this space. So I would appreciate if you opined biased to disillusion my confusion.
- tiglionabbit 11y agoGraphQL lets you represent your API as a graph. You do this by defining a set of types that have fields in them which resolve to instances of other types. For example, if you have a "Person" type with a "friends" field that resolves to more people, you could traverse this as deeply as you wanted, like so: query { me { friends { friends { friends { friends { name } } } } } } That would get you the names of my friends of friends of friends of friends. It's a directed graph where you can traverse as many edges as you want in any direction in a single query. It's like a power tools version of your usual REST API. What more are you expecting? (in relay this would look a bit different due to the "connection" spec, but you're free to define a graphql endpoint this way too)