-
Notifications
You must be signed in to change notification settings - Fork 279
feat(api): implement graphql merge query pattern to reduce api call volume #2478
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
Conversation
|
Current state of this PR is functional, but needs some further polish / refactoring, and update tests before being ready |
d09207b to
02866a2
Compare
- Add query merging infrastructure to batch multiple GraphQL queries into one - Create BatchMergedDetailsQueryFragment for combined notification queries - Update handlers (Discussion, Issue, PullRequest) with mergeQueryConfig - Add INDEX suffix variable naming for merged query support - Create getNotificationAuthor helper to handle snake_case/camelCase formats - Guard against null URLs in notification enrichment - Update test mocks to use nodeINDEX response format Co-authored-by: Adam Setch <adam.setch@outlook.com>
- Remove commented-out debug code from notifications.ts - Fix FIXME by using isAnsweredDiscussionFeatureSupported with account - Remove unused extras field from GraphQLMergedQueryConfig type - Add mergeQueryConfig tests for issue, pullRequest, discussion, and default handlers - Document why integration test is skipped (complex mocking requirements)
c85feb4 to
27e5321
Compare
|
@afonsojramos - this isn't ready yet, it's still very much a draft |
|
Just wanted another pair of eyes! I'll keep working on this tomorrow 🙈 |
Not ready yet, I have changed I'd like to make to it still...
What happened to my previous work on this branch, it seems you've rewrote the history and made other changes without discussion... I have local changes that I now need to untangle... |
Signed-off-by: Adam Setch <adam.setch@outlook.com>
…clash in merged query Signed-off-by: Adam Setch <adam.setch@outlook.com>
Signed-off-by: Adam Setch <adam.setch@outlook.com>
Signed-off-by: Adam Setch <adam.setch@outlook.com>
Signed-off-by: Adam Setch <adam.setch@outlook.com>
…on draft PR Signed-off-by: Adam Setch <adam.setch@outlook.com>
Signed-off-by: Adam Setch <adam.setch@outlook.com>
Signed-off-by: Adam Setch <adam.setch@outlook.com>
Signed-off-by: Adam Setch <adam.setch@outlook.com>
Signed-off-by: Adam Setch <adam.setch@outlook.com>
Signed-off-by: Adam Setch <adam.setch@outlook.com>
|
Sometime tomorrow I'll verify if this merge query approach actually is more efficient for the API Quotas / Rate Limits. If similar, this complexity may not warrant the effort to maintain... |
afonsojramos
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In addition to inline comments, currently, all supported notifications are batched into a single query. For large notification lists, this could create extremely large queries.
Shall we consider:
- Setting a maximum batch size
- Have a way to track the complexity of the query
- If merged queries repeatedly fail, fall back to individual queries
Based on this, this PR seems to add a lot of complexity. Do we really wan't it? 😬
src/renderer/utils/api/client.ts
Outdated
| builder.setNonIndexedVars({ | ||
| includeIsAnswered: isAnsweredDiscussionFeatureSupported( | ||
| notifications[0].account, | ||
| ), | ||
| firstClosingIssues: Constants.GRAPHQL_ARGS.FIRST_CLOSING_ISSUES, | ||
| firstLabels: Constants.GRAPHQL_ARGS.FIRST_LABELS, | ||
| lastComments: Constants.GRAPHQL_ARGS.LAST_COMMENTS, | ||
| lastThreadedComments: Constants.GRAPHQL_ARGS.LAST_THREADED_COMMENTS, | ||
| lastReplies: Constants.GRAPHQL_ARGS.LAST_REPLIES, | ||
| lastReviews: Constants.GRAPHQL_ARGS.LAST_REVIEWS, | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this assuming that notifications all belong to the same account?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's correct
The flow of notifications.ts is currently:
notifications/getNotificationsfetches the notification list per Gitify accountnotifications/getAllNotificationsiterates over each Gitify account and base filters, enriches and detail filters
Updated analysis on quota consumption below... Note: REST and GraphQL API Quotas as independent Configuration
|
afonsojramos
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Testing looks awesome! Just some function naming proposals, but looks good overall!
… batching vs query merging Signed-off-by: Adam Setch <adam.setch@outlook.com>
… batching vs query merging Signed-off-by: Adam Setch <adam.setch@outlook.com>
Signed-off-by: Adam Setch <adam.setch@outlook.com>
Signed-off-by: Adam Setch <adam.setch@outlook.com>
Signed-off-by: Adam Setch <adam.setch@outlook.com>
Signed-off-by: Adam Setch <adam.setch@outlook.com>
Signed-off-by: Adam Setch <adam.setch@outlook.com>
Signed-off-by: Adam Setch <adam.setch@outlook.com>
Signed-off-by: Adam Setch <adam.setch@outlook.com>
Signed-off-by: Adam Setch <adam.setch@outlook.com>
Signed-off-by: Adam Setch <adam.setch@outlook.com>
|






Implement GraphQL query aliasing and merging to reduce network calls and better utilize GitHub API rate limits
v6.14.1release buildFor Issues, Pull Requests or Discussions, full enrichment now occurs in a single API query with a maximum query cost of 4 units