Add GraphQL API for Wiki notes

What does this MR do and why?

Related to #468799 (closed).

This adds GraphQL API backend for Wiki notes previously added in !163305 (merged), complete with a WikiPageType, resolver, and all the glue code.

Additionally:

  • Removed WikiPage::MetaPolicy and consolidated it into existing WikiPagePolicy. There's no reason for the meta record to have a separate set of permissions (at least for now).
  • Fixed Note URL generation for group wikis and added a missing spec for it. I can't easily separate this out of this MR, because some group wiki specs rely on it working.

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Before After

How to set up and validate locally

  1. Add a new wiki and a wiki page (this creates an associated WikiPage::Meta record for the wiki page, which is used as the noteable object).
  2. Do the calls:
Reading a wiki page
fragment Author on User {
  id
  avatarUrl
  name
  username
  webUrl
  webPath
}


fragment WikiPageNote on Note {
  id
  author {
    ...Author
  }
  body
  bodyHtml
  createdAt
  lastEditedAt
  url
  userPermissions {
    adminNote
    awardEmoji
    readNote
    createNote
    resolveNote
    repositionNote
  }
  discussion {
    id
    resolved
    resolvable
    resolvedBy {
      id
      name
    }
  }
}

{
  wikiPage(slug: "home", projectId: "gid://gitlab/Project/7") {
    id
    title
    discussions {
      nodes {
        id
        replyId
        resolvable
        resolved
        resolvedAt
        resolvedBy {
          id
          name
        }
        notes {
          nodes {
            ...WikiPageNote
          }
        }
      }
    }
  }
}
Creating a wiki page note
fragment Author on User {
  id
  avatarUrl
  name
  username
  webUrl
  webPath
}


fragment WikiPageNote on Note {
  id
  author {
    ...Author
  }
  body
  bodyHtml
  createdAt
  lastEditedAt
  url
  userPermissions {
    adminNote
    awardEmoji
    readNote
    createNote
    resolveNote
    repositionNote
  }
  discussion {
    id
    resolved
    resolvable
    resolvedBy {
      id
      name
    }
  }
}

mutation createWikiPageNote($input: CreateNoteInput!) {
  createNote(input: $input) {
    note {
      id
      discussion {
        id
        notes {
          nodes {
            ...WikiPageNote
          }
        }
      }
    }
    errors
  }
}

# Variables

{
    "input": {
        "noteableId": "gid://gitlab/WikiPage::Meta/1",
        "body": "Test Note",
        "discussionId": null,
        "internal": false
    }
}
Edited by Piotr Skorupa

Merge request reports

Loading