For the memberRoleCreate mutation, allow an array to be passed instead of individually setting boolean fields

Currently, the memberRoleCreate mutation has each permission as its own field:

ksnip_20231121-022616

This creates additional burden on the frontend because when fetching available permissions, the data is returned as an array:

ksnip_20231121-021030

In order to use the memberRoleCreate mutation, we would need to convert the string ID to a GraphQL boolean field. For example, we would need to use this GraphQL query:

mutation memberRoleCreate(
  $adminMergeRequest: Boolean = false,
  $adminVulnerability: Boolean = false, 
  $readCode: Boolean = false) {
  memberRoleCreate(input: {
    adminMergeRequest: $adminMergeRequest,
    adminVulnerability: $adminVulnerability,
    readCode: $readCode,
  })
}

with this frontend code:

this.$apollo.mutate({
  query: memberRoleCreateQuery,
  variables: {
    adminMergeRequest: this.selectedPermissions.includes('admin_merge_request'),
    adminVulnerability: this.selectedPermissions.includes('admin_vulnerability'),
    readCode: this.selectedPermissions.includes('read_code'),
  }
})

It has the following issues:

  1. This is ok for a few permissions, but requires a ton of boilerplate code once we have a lot of permissions.

  2. Every time someone adds a new permission, they need to update both the query and the frontend code that uses the query.

  3. Because the GraphQL query is sent to the backend for processing, there's a limit to how big it can be before backend returns a "query too long" error. We can easily exceed that limit once we have a lot of permissions.

To avoid the above issues, we should introduce a new mutation field that lets us pass in an array of strings.

Proposed mutation

mutation memberRoleCreate($permissions: [String!]) {
  memberRoleCreate(input: {
    permissions: $permissions
  })
}
Edited by Daniel Tian