Comments (4)
I'm going to work on it ;)
from relay.
There is an issue as a lot of databases doesn't support the backward pagination.
The simplest solution would be to sort the results backward before applying the limit/offset.
We would maybe need a third return boolean parameter reverse
.
Or maybe use negative offset
and limit
values.
from relay.
hi @solher thanks for taking your time to look into this project, appreciate it very much 👍🏻
If the client asks for the first two elements, we potentially query 10000 documents from the database before throwing away the 9998 we don't want.
So the example solution you gave seems about right and it would address your issue, except that current relay-go
library is missing a couple of pieces that would help to make it work
relay.computeOffset
: Actually there is alreadyrelay.getOffset()
.
It translates a connection cursor string to an offset value that you can use to construct your query for your data source (SQL, Mongo etc)
This is currently a private method. This should be exposed and make it available.relay.ConnectionFromArray()
assume that the input data is static or representative of the whole data collection. Thats why currently your implementation might have to get every data for it to return correct cursor Connection value. And you are right to think that this is not ideal.
The missing piece is actually relay.ConnectionFromSliceArray()
introduced a couple of months back in relay-js
.
This has not been ported to relay-go
{ConnectionFromSliceArray} effectively allows you to fetch the data for a subset of a connection, and pass that in with some metadata indicating where the subsequence starts and how long the total array would be if materialized, and get a connection object back.
I can't personally commit when these changes would be made available but PRs are greatly welcomed!
Hope this answers your question!
TODO:
- Expose
relay.GetOffset()
- Port and expose
relay.ConnectionFromSliceArray()
- Secondary todo: Port latest changes from
relay-js
torelay-go
(From 0.3.2 to 0.3.6)
from relay.
Merged PR #22
Thanks @solher 👍🏻
from relay.
Related Issues (20)
- Bug: MutationFn error parameter HOT 1
- Context support HOT 4
- IDFetcher to return error HOT 3
- IDFetcher and resolving fields to prevent over fetching HOT 5
- Variable "$id_0" of type "ID" used in position expecting type "ID!" after upgrading to relay 0.7.0.0 HOT 1
- MutationFn, IDFetcherFn signature to follow conventions
- Tests use old format for ResolveTypeFn HOT 1
- "starwars" example currently broken HOT 4
- Is this project still active? HOT 1
- Relay Modern Support? HOT 1
- Demo offline
- Project status HOT 7
- Relay Modern support HOT 2
- Question: Use of ConnectionArguments HOT 1
- Add .travis.yml HOT 1
- FieldConfigArgument descriptions are not used in GraphiQL
- ConnectionDefinitions should accept a Interface
- MutationWithClientMutationID retain the mutation name HOT 1
- Feature Request - Push messaging HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from relay.