Skip to content

GraphQL: Add fields selection to export requirements mutation

What does this MR do?

Related to #290823 (closed)

As the next iteration for !50546 (merged) we want to allow the mutation to accept a new argument that will be an array of strings indicating which fields should be included in the exported CSV file.

For this to be possible we need to include the new argument in the worker that is called from the mutation: IssuableExportCsvWorker. Then this worker will call the export service (RequirementsManagement::ExportCsvService in this case) that will filter the selected fields.

New mutation argument selectedFields:

  • Mutation
mutation {
  exportRequirements(input: {projectPath: "group-1/project-1", state: OPENED, sort: CREATED_DESC, search: "test", selectedFields: ["title", "description"]}) {
    errors
  }
}
Response
{
  "data": {
    "exportRequirements": {
      "errors": []
    }
  }
}
Response with error
{
  "data": {
    "exportRequirements": null
  },
  "errors": [
    {
      "message": "The following fields are incorrect: IID. See https://docs.gitlab.com/ee/user/project/requirements/#exported-csv-file-format for permitted fields.",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "exportRequirements"
      ]
    }
  ]
}

Screenshots (strongly suggested)

All columns Selected columns only
Screen_Shot_2021-01-28_at_15.14.35 Screen_Shot_2021-01-28_at_15.14.15

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team
Edited by Eugenia Grieff

Merge request reports