Skip to content

Allow Filtering by subscribed issues in the graphql api

Brett Walker requested to merge bw-add-subscribed-filter into master

What does this MR do?

For the initial functionality, we're only supporting explicit subscriptions. This means you've either specifically turned notification on or off for an issue. This does not include implicit subscriptions, which would be issues you've commented on, awarded, etc.


NOTE: Original description below. This is in place of Allow Filtering by subscribed issues in the gra... (!111531 - closed), where the commit chain got a little boinked up.

This MR allows a user to filter issues to only the subscribed issues within the graphql api. Subscribed Issues are issues where you are receiving email notifications and where the toggle on the bottom right of the right sidebar is on.

This offers an API-based solution to the problem in this issue: #14972

However, It only exposed exlicitly subscribed issues.

Rather than doing this to close any particular issue, I'm opening this because I would personally like to use this endpoint in my day to day work. The related issue has 300 👍 emojis.

Query plan using my user id and the gitlab-org/gitlab project with 3 years of subscriptions:

SELECT "issues".* FROM "issues" INNER JOIN "subscriptions" ON "subscriptions"."subscribable_type" = 'Issue' AND "subscriptions"."subscribable_id" = "issues"."id" WHERE "issues"."project_id" = 278964 AND "subscriptions"."user_id" = 4626651 ORDER BY "issues"."created_at" DESC, "issues"."id" DESC LIMIT 101;

https://console.postgres.ai/gitlab/gitlab-production-tunnel-pg12/sessions/15326/commands/53339

Screenshots or Screencasts (strongly suggested)

Screen_Shot_2021-07-13_at_4.27.48_PM

Screen_Shot_2021-07-13_at_4.27.57_PM

How to set up and validate locally

  1. Go the project flightjs/Flight on your local system.

  2. Go into an issue and turn off and then on the notifications for the issue (either in the triple dot menu, or the new notification icon in the upper right of an issue). This ensures that the issue is explicitly subscribed.

  3. Go into another issue and turn off the notifications.

  4. Go to the graphql explorer, such as http://ee.gitlab.test:5100/-/graphql-explorer, and use the following query

     query {
       project(fullPath: "flightjs/Flight") {
         issues(subscribed: true) {
           nodes {
             id
             subscribed
           }
         }
       }
     }
  5. you should see the listed just the issue with the notifications explicitly turned on.

  6. Use false in the query and you should see the issue with the notifications turned off.

  7. Note that if you remove the subscribed parameter, and show all issues, the subscribed attribute that is show will reflect explicit and implicit subscriptions. This is ok for this iteration.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Brett Walker

Merge request reports