Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

connectionFromArray should populate count and totalCount automatically #225

Open
youngkidwarrior opened this issue Apr 27, 2019 · 3 comments

Comments

@youngkidwarrior
Copy link

I recently dove headfirst into relay modern and whilst I was setting up my queries, I noticed my count fields were returning null in graphiQL. I had assumed connextionFromArray was meant to automatically give me count and totalCount of the passed in array for pagination.

@youngkidwarrior
Copy link
Author

To follow up, I believe all it would take is doing arr.length and connection.edges.length. Am I correct?

@koistya
Copy link
Contributor

koistya commented May 7, 2019

You may want to look into unit tests to see how it's designed to work:

https://github.com/graphql/graphql-relay-js/blob/master/src/connection/__tests__/arrayconnection.js

@youngkidwarrior
Copy link
Author

youngkidwarrior commented May 7, 2019

I guess I just don't understand why you wouldn't run those length operations.
Can't count just be another filter that uses edges.length? Does it break something? or just add unintended functionality.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants