Comments (15)
Would depend on how the query is modified in the backend. A proper approach should be established first.
I've documented the standard approach to be followed throughout talawa-api for implementing pagination using the graphql connections:- https://docs.talawa.io/docs/developers/talawa-api/pagination
Implement pagination for EventsByOrganization
Again, REST like patterns should not to be followed with graphql, relationships and fetching patterns should be expressed in the graph. This is an anti-pattern:-
type Query {
eventsByOrganization(organizationID: ID!): EventsConnection
}
The events associated to an organization should be exposed like this:-
type Organization {
events: EventsConnection
}
On the client side querying for the events within an organization would look like this:-
type OrganizationEventsQuery($cursor: String, $limit: Int!, $organizationID: ID!) {
organization(id: $organizationID) {
address
phoneNumber
events(first: $limit, after: $cursor) {
edges {
cursor
node {
id
...other event fields
}
}
pageInfo {
... fields
}
}
}
name
}
The advantage here is that you can fetch other fields like address
, phoneNumber
, name
etc., that exist on the organization along with the events associated to that organization. This is more efficient because the client only sends 1 network request to fetch everything that is needed. The server takes care of resolving everything listed in the query.
When the next set of events are to be fetched(connection is to be traversed further) a new network request would be made with a non-null value for the $cursor
variable. This time there's no need to fetch the organization fields like address, phoneNumber, name etc., because they were already fetched by the very first network request. This would look like this:-
type OrganizationEventsQuery($cursor: String, $limit: Int!, $organizationID: ID!) {
organization(id: $organizationID) {
events(first: $limit, after: $cursor) {
edges {
cursor
node {
id
...other event fields
}
}
pageInfo {
... fields
}
}
}
}
To understand how the client implementation would work, take a read:-
- https://www.apollographql.com/docs/react/pagination/overview
- https://www.apollographql.com/docs/react/pagination/core-api
- https://www.apollographql.com/docs/react/pagination/cursor-based#relay-style-cursor-pagination
- https://commerce.nearform.com/open-source/urql/docs/basics/ui-patterns/#infinite-scrolling
- https://commerce.nearform.com/open-source/urql/docs/graphcache/local-resolvers/#pagination
from talawa-api.
Yes kindly do it. Thanks.
from talawa-api.
@aashimawadhwa @rishav-jha-mech @DMills27 PTAL and comment
from talawa-api.
@xoldd This was discussed frequently in the past, however related to news feeds. PTAL too
from talawa-api.
@Azad99-9 @meetulr Do you think this can be implemented without the UI/UX functionality being affected for both Admin and Mobile?
from talawa-api.
@palisadoes For the mobile part the UI should be tweaked to accomodate the pagination.
from talawa-api.
Both the admin and mobile will need to be updated simultaneously according to the changes in the API. We'll need contributors for both. Would depend on how the query is modified in the backend. A proper approach should be established first.
from talawa-api.
- That's what I figured. We don't want to break the apps.
- Will we need to modify the newsfeed and its infinite scrolling?
from talawa-api.
When the next set of events are to be fetched(connection is to be traversed further) a new network request would be made with a non-null value for the $cursor variable. This time there's no need to fetch the organization fields like address, phoneNumber, name etc., because they were already fetched by the very first network request. This would look like this:-
Yes we already use a similar approach in organizationsConnection
query.
from talawa-api.
@Azad99-9 Are you working on this?
from talawa-api.
@palisadoes I am not working on this. But this needs to be addressed. To resolve client side performance issues.
from talawa-api.
Should I do it?
from talawa-api.
hey, is this issue up? can i be assigned to do this?.
from talawa-api.
@Maniii97 Thank you for your interest. Please keep looking, as I'm sure we have open issues and we'd love your help. If any issue is already assigned, please don't ask to be assigned. We want everyone to get a chance.
from talawa-api.
This issue did not get any activity in the past 10 days and will be closed in 180 days if no update occurs. Please check if the develop branch has fixed it and report again or close the issue.
from talawa-api.
Related Issues (20)
- Feature Request: Query for AgendaItemCategories by Organization
- Bug Report: Agenda Item & Section Mutation and Query not working
- Upgrade package mongoose from 8.3.2 to 8.4.4 HOT 12
- Feature Request: Query for AgendaItem by Event and Organization
- [BUG] Cast to ObjectId failed for value "" (type string) at path "_id" for model "Organization" HOT 1
- [BUG] npm run dev Restarting 'src/index.ts' file again & again
- Feature Request: Change updatedBy field to userId from context
- Migrate from Nginx to Caddy for Reverse Proxy in Cloud API Demo HOT 5
- Add Sort support to fundsByOrganization & getFundById resolvers and Refac HOT 2
- Feature Request: sort the agendaItem based on sequence in query
- Bug Report: Error in typedoc theme
- Feature Request: Enhance documentation Comments for config,directives, helpers directory (Part-1)
- Upgrade package graphql from 16.8.1 to 16.9.0 HOT 1
- [Translation] Errors from API don't translate
- Feature Request: Create a installation script to simplifies the project setup HOT 1
- Add organization userTags connection (GSoC) HOT 1
- Upgrade packages vitest and @vitest/coverage-v8
- Upgrade package react-i18next from 11.18.6 to 12.3.1
- Implement mutations for DirectChat and GroupChat and fix subscriptions (GSOC) HOT 2
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 talawa-api.