Skip to content

Add id param to Achievements GraphQL type

What does this MR do and why?

I have started to work on https://gitlab.com/gitlab-org/community-relations/contributor-success/team-task/-/issues/207 and realise we need to be able to grab a single achievement and at the moment can only grab all achievements for a group.

This MR adds the id argument to support our requirement.

How to set up and validate locally

From rails console:

  • Feature.enable(:achievements)
  • FactoryBot.create_list(:achievement, 2, namespace: Group.first)
  • Grab the returned namespace_id
  • Grab the full_path Namespace.find(<namespace_id>).full_path
  • From http://gdk.test:3000/-/graphql-explorer
    query getAchievements {
    namespace(fullPath: "<full_path>") {
      achievements {
        nodes {
          id
          name
          description
        }
      }
    }
    }
  • Now try to just grab one:
    ```graphql
    query getAchievements {
    namespace(fullPath: "<full_path>") {
      achievements(id: "gid://gitlab/Achievements::Achievement/<achievement_id>") {
        nodes {
          id
          name
          description
        }
      }
    }
    }

If you have any problems, try deleting all achievements from the rails console: Achievements::Achievement.delete_all then re-running the seed script (not from the rails console): bundle exec rake db:seed_fu FILTER=36_achievements 🤞

MR acceptance checklist

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

Merge request reports