I decided to extend the range properties inside the pageInfo object. I added a field named totalCount in my custom connection, although it worked very well In GPQL I soon realized that that my pageInfo is overwritten in GraphQLRange.js according to the fields set up in RelayOSSConnectionInterface.js allowing only: END_CURSOR START_CURSOR HAS_NEXT_PAGE and HAS_PREV_PAGE fields. So I had no other option than to rename pageInfo to something completely different in my schema.
I don't know enough about the library to know why the library re-creates the pageInfo object even when the graphql backend provides that data... caching ?
Although this can be fixed by renaming the pagination object, It's not entirely clear to me why the solution is setup this way.
Also I wonder if the spect does not allow for custom fields on the pageInfo object, if it does I might be interested in submitting a fix to allow custom fields...
Relay has special cases logic for handling connections, including the pageInfo field. This field is used to record whether or not more edges may be available, in order to build a representation of what portions of the possible edges are fetched locally. The full pageInfo result is not actually stored; when you query for pageInfo in a component fragment, Relay synthesizes the results based on the first/after/etc calls you supplied and its knowledge of which edges are available.
In general we recommend storing connection-level fields such as totalCount _on the connection_. In this case, that would look roughly like the following:
fragment on Foo {
friends(first: $n) {
totalCount # Connection metadata
edges {
cursor
friendsSince # edge metadata
node { ... }}}
If you have any further questions about the framework, feel free to file an issue here. If you have usage questions about Relay or connections, please do open a question at https://stackoverflow.com/questions/ask?tags=relayjs
Most helpful comment
Relay has special cases logic for handling connections, including the pageInfo field. This field is used to record whether or not more edges may be available, in order to build a representation of what portions of the possible edges are fetched locally. The full pageInfo result is not actually stored; when you query for pageInfo in a component fragment, Relay synthesizes the results based on the first/after/etc calls you supplied and its knowledge of which edges are available.
In general we recommend storing connection-level fields such as totalCount _on the connection_. In this case, that would look roughly like the following: