Hi all! I'm confused about why sometime subselecti...
# prisma-whats-new
c
Hi all! I'm confused about why sometime subselections are done directly, and sometimes through "edges". For example { trainer(id: 1) { name pokemon { name, level } } vs { trainer(id: 1) { name edges { node { name, level } } Basically, I don't see the value added of edges. It is kind of like with graphs sometimes a node can refer directly to another node, and sometimes there is actually a discrete edge object? If that's the case, is there some sort of notion of edge "weight" we are trying to reflect when we use edges? Or am I overthinking all this, and is edges just part of the relay boilerplate api code?
a
@cadbot Where did you get the example with edges?
c
That was a hypothetical example
Is it malformed?
a
Ah no I see what you’re saying, I should ask where were you seeing that selections are sometimes done through edges? I’ve actually never heard of that
However I would say that if you’re starting on graphcool right now you’ll be fine without using edges
c
I'll use a working example instead. Let's say we are using the star wars graphql endpoint: http://graphql.org/swapi-graphql/ here is a valid query: { allFilms { films { title releaseDate producers } } } another query that appears to work the same { allFilms { edges { node { title releaseDate producers } } } }
The detail I'm missing is why one would or wouldn't want to use edges?
It feels like nothing more than a layer of indirection
But I feel like I might be missing something here 🙂
a
I suppose then like you were saying if there were edge weights
n
so the thing is
Whenever a field returns a list of things in a Relay compliant API, it will return a list field called "edges" that contains many "node" fields
it's not about the root query but about the connection
Graphcool comes with both a Relay API and a simpler API with a similar feature set that we call Simple API
c
Oh! I think I saw my own point about edges a little bit. The fields totalCount, pageInfo etc... can be thought of as "weights" for the edge
n
https://www.graph.cool/docs/tutorials/relay-vs-apollo-iechu0shia/ here are some more thoughts about Relay and Apollo. Apollo also works with APIs that don't use edges and nodes
yes that's correct
it's really a graph then :)
c
I see, so I'm using the "simple" API when I don't have edges, and in order to interact with Relay, it must be specified using edges as part of the api. The additional benefit of this is metadata about the edge itself (the weights)
Thanks all!
I'll read through that article and probably come back with some affirmations 🙂 Thanks!
n
Yep, there are a few other things that Relay requires as well. Would love to hear your thoughts after you read the article 🙌