Skip to content

Add issues set crm contacts service and graphql mutation

Lee Tickett requested to merge graphql-allow-update-issue-contacts into master

What does this MR do and why?

See #2256 for an overview on the Customer Relations / CRM feature and work completed so far.

This MR inroduces a new graphql mutation for setting/adding/removing customer relations contacts to/from issues (and the required service to support it)

Screenshots or screen recordings

image

How to set up and validate locally

From rails console:
1. Enable feature flag:
Feature.enable(:customer_relations)
From GraphiQL:
2. Pick a an issue (I used http://gdk.test:3000/flightjs/Flight/-/issues/30)
3. Create a few contacts for the group the issue belongs to (and take note of their ids):
mutation {
  customerRelationsContactCreate(input:
    {
      groupId: "gid://gitlab/Group/26"
      firstName: "Lee"
      lastName: "Tickett"
    }) {
    contact {
      id
      firstName
      lastName
    }
    errors
  }
}
4. Try and APPEND/REMOVE/REPLACE the contacts assigned to the issue:
mutation {
  issueSetCrmContacts(input:
    {
      projectPath: "flightjs/Flight"
      iid: "30"
      operationMode: APPEND
      crmContactIds: [
        "gid://gitlab/CustomerRelations::Contact/14",
        "gid://gitlab/CustomerRelations::Contact/12"
      ]
    }) {
    issue {
     id
      customerRelationsContacts {
        nodes {
          id
          firstName
          lastName
        }
      }
    }
    errors
  }
}
--
mutation {
  issueSetCrmContacts(input:
    {
      projectPath: "flightjs/Flight"
      iid: "30"
      operationMode: REPLACE
      crmContactIds: [
        "gid://gitlab/CustomerRelations::Contact/11",
        "gid://gitlab/CustomerRelations::Contact/12"
      ]
    }) {
    issue {
     id
      customerRelationsContacts {
        nodes {
          id
          firstName
          lastName
        }
      }
    }
    errors
  }
}
--
mutation {
  issueSetCrmContacts(input:
    {
      projectPath: "flightjs/Flight"
      iid: "30"
      operationMode: REMOVE
      crmContactIds: [
        "gid://gitlab/CustomerRelations::Contact/12"
      ]
    }) {
    issue {
     id
      customerRelationsContacts {
        nodes {
          id
          firstName
          lastName
        }
      }
    }
    errors
  }
}

MR acceptance checklist

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

Edited by Alex Kalderimis

Merge request reports

Loading