Skip to content

Refactoring to graphql error message handling

MR: Pending

Description

The following discussion from !135413 (merged) should be addressed:

  • @cwoolley-gitlab started a discussion:

    Now that this is duplicated 3 times, lets pull it out to a separate module to dry it up:

    But let's do this in a separate MR, and do a bigger refactor cleanup. See related thread here: !136653 (comment 1678862436)

    1. Pull #raise_resource_not_available_error! out of Gitlab::Graphql::Authorize::AuthorizeResource so it can be used independently even for classes that have no need to work with a related object or resource (e.g. root query resolvers like the one in !136653 (comment 1678862436)
    2. New module can be something like Gitlab::Graphql::Authorize::ErrorMessageHandling
    3. To the new module, add a new helper method like ensure_licensed_feature_available!(feature) which has the behavior of these lines. I.e., check for the license, and return a friendly and useful error message if it doesn't.

Acceptance Criteria

  • Duplication is removed as described in the description of this issue

Technical Requirements

  • See description for details
Edited by Chad Woolley