Coder Social home page Coder Social logo

Comments (5)

dschafer avatar dschafer commented on May 5, 2024 3

Note that while Relay requires edges for its pagination, it doesn't have an opinion on whether nodes is exposed. So if you find nodes convenient for browsing APIs (I certainly do), I'd definitely add it in! If you do so, Relay has a check in place so that if you query for nodes instead of edges, it will warn and suggest querying for edges instead.

from graphql-relay-js.

yuzhi avatar yuzhi commented on May 5, 2024 2

We fetch cursors on every edge so that if you have a component that asks for first:10 and have it cached and later another component asks for first:5, we can generated the correct pageInfo based on the cursors we have fetched from first:10 for first:5 without doing a server round trip.
Another case is, if some of the edges are deleted through mutations, we still have the cursors form the other edges to fetch for additional edges.

from graphql-relay-js.

dschafer avatar dschafer commented on May 5, 2024

CC @yuzhi who can describe what the Relay store does with the cursors on each edge, and hence why it uses edges rather than nodes.

Internally, we expose nodes for exactly the reason you describe: if you don't need edge data or the cursor, it's quite convenient to skip straight to the nodes; that's definitely a useful pattern.

from graphql-relay-js.

luisobo avatar luisobo commented on May 5, 2024

Yeah, that's what @leebyron suggested on graphql/graphql-spec#4.

Can't what to hear the purpose of that. I'm guessing something related to nodes being evicted out of a local cache and refetching parts of a connection?

from graphql-relay-js.

luisobo avatar luisobo commented on May 5, 2024

Interesting thanks!

/cc @modocache @akatz

On Tuesday, September 22, 2015, Yuzhi [email protected] wrote:

We fetch cursors on every edge so that if you have a component that asks
for first:10 and have it cached and later another component asks for
first:5, we can generated the correct pageInfo based on the cursors we
have fetched from first:10 for first:5 without doing a server round trip.
Another case is, if some of the edges are deleted through mutations, we
still have the cursors form the other edges to fetch for additional edges.


Reply to this email directly or view it on GitHub
#27 (comment)
.

from graphql-relay-js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.