Skip to content
This repository has been archived by the owner on Nov 19, 2024. It is now read-only.

Commit

Permalink
ISSUE-7987: The GraphQL topic "Company team mutations" has been creat…
Browse files Browse the repository at this point in the history
…ed (#8028)

* ISSUE-7987: The topic "Company team mutations" has been created

* ISSUE-7987: Fixes according to reviewer proposal

* Update company-team.md

* Update company-team-mutations.md

* Update company-team.md

* Update company-team-mutations.md

* ISSUE-7987: Small fixes

- separating the topics;
- adding the links

* Update graphql.yml

* Small fixes

Co-authored-by: Kevin Harper <[email protected]>
  • Loading branch information
andrewbess and keharper authored Oct 16, 2020
1 parent abb7604 commit 2f1dd22
Show file tree
Hide file tree
Showing 6 changed files with 425 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/_data/toc/graphql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,11 @@ pages:
edition: b2b-only
exclude_versions: ["2.3"]

- label: createCompanyTeam mutation
url: /graphql/mutations/create-company-team.html
edition: b2b-only
exclude_versions: ["2.3"]

- label: createCustomer mutation
url: /graphql/mutations/create-customer.html

Expand Down Expand Up @@ -250,6 +255,11 @@ pages:
edition: ee-only
exclude_versions: ["2.3"]

- label: deleteCompanyTeam mutation
url: /graphql/mutations/delete-company-team.html
edition: b2b-only
exclude_versions: ["2.3"]

- label: deleteCustomerAddress mutation
url: /graphql/mutations/delete-customer-address.html

Expand Down Expand Up @@ -357,6 +367,16 @@ pages:
edition: b2b-only
exclude_versions: ["2.3"]

- label: updateCompanyStructure mutation
url: /graphql/mutations/update-company-structure.html
edition: b2b-only
exclude_versions: ["2.3"]

- label: updateCompanyTeam mutation
url: /graphql/mutations/update-company-team.html
edition: b2b-only
exclude_versions: ["2.3"]

- label: updateCustomer mutation
url: /graphql/mutations/update-customer.html

Expand Down
7 changes: 7 additions & 0 deletions src/_includes/graphql/company-team.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
The `CompanyTeam` object contains details about a company team. It contains the following attributes.

Attribute | Data Type | Description
--- | --- | ---
`description` | String | An optional description of the team
`id` | ID! | A string that contains the encoded team ID
`name` | String | The display name of the team
127 changes: 127 additions & 0 deletions src/guides/v2.4/graphql/mutations/create-company-team.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
---
group: graphql
title: createCompanyTeam mutation
contributor_name: Atwix
contributor_link: https://www.atwix.com/
b2b_only: true
---

Use the `createCompanyTeam` mutation to create a new team for your company.

The `target_id` input attribute allows you to specify which node in the company structure will be the parent node of the company team. If you do not specify a value, the team will be assigned to the top-level (root) node of the company structure.

You can get the `target_id` with the [`company`]({{page.baseurl}}/graphql/queries/company.html) query.

## Syntax

```graphql
mutation {
createCompanyTeam(
input: CompanyTeamCreateInput!
) {
CreateCompanyTeamOutput
}
}
```

## Example usage

The following example shows the minimal payload for adding a new team to a customer's company.

**Request:**

```graphql
mutation {
createCompanyTeam(
input: {
name: "Test Team"
}
) {
team {
id
name
description
}
}
}
```

**Response:**

```json
{
"data": {
"createCompanyTeam": {
"team": {
"id": "MQ==",
"name": "Test Team",
"description": null
}
}
}
}
```

This example creates a child team of the parent team specified in the `target_id` field.

**Request:**

```graphql
mutation {
createCompanyTeam(
input: {
name: "Test Child Team"
description: "Test Child Team description"
target_id: "MQ=="
}
) {
team {
id
name
description
}
}
}
```

**Response:**

```json
{
"data": {
"createCompanyTeam": {
"team": {
"id": "Mg==",
"name": "Test Child Team",
"description": "Test Child Team description"
}
}
}
}
```

## Input attributes

The `CompanyTeamCreateInput` input object defines the company team data.

### CompanyTeamCreateInput attributes {#CompanyTeamCreateInput}

The `CompanyTeamCreateInput` object contains the following attributes:

Attribute | Data Type | Description
--- | --- | ---
`description` | String | An optional description of the team
`name` | String! | The display name of the team
`target_id` | ID | The ID of a node within a company's structure. This ID will be the parent of the created team

## Output attributes

The `CreateCompanyTeamOutput` output object contains the following attribute:

Attribute | Data Type | Description
--- | --- | ---
`team` | CompanyTeam! | Contains company team data

### CompanyTeam attributes {#CompanyTeam}

{% include graphql/company-team.md %}
61 changes: 61 additions & 0 deletions src/guides/v2.4/graphql/mutations/delete-company-team.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
---
group: graphql
title: deleteCompanyTeam mutation
contributor_name: Atwix
contributor_link: https://www.atwix.com/
b2b_only: true
---

Use the `deleteCompanyTeam` mutation to delete a company team by ID. You can get the team ID with the [`company`]({{page.baseurl}}/graphql/queries/company.html) query.

## Syntax

```graphql
mutation {
deleteCompanyTeam(
id: ID!
) {
DeleteCompanyTeamOutput
}
}
```

## Example usage

The following example deletes the specified team.

**Request:**

```graphql
mutation {
deleteCompanyTeam(
id: "Mg=="
) {
success
}
}
```

**Response:**

```json
{
"data": {
"deleteCompanyTeam": {
"success": true
}
}
}
```

## Input attributes

The `deleteCompanyTeam` mutation requires the following input:

Attribute | Data Type | Description
--- | --- | ---
`id` | ID! | The encoded team ID to delete

## Output attributes

The `deleteCompanyTeam` mutation returns a Boolean value that indicates whether the operation was successful.
121 changes: 121 additions & 0 deletions src/guides/v2.4/graphql/mutations/update-company-structure.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
---
group: graphql
title: updateCompanyStructure mutation
contributor_name: Atwix
contributor_link: https://www.atwix.com/
b2b_only: true
---

Use the `updateCompanyStructure` mutation to change the parent node of a company team.

## Syntax

```graphql
mutation {
updateCompanyStructure(
input: CompanyStructureUpdateInput!
) {
UpdateCompanyStructureOutput
}
}
```

## Example usage

The following example shows how to update the customer's company structure.

**Request:**

```graphql
mutation {
updateCompanyStructure(
input: {
tree_id: "Mw=="
parent_tree_id: "MQ=="
}
) {
company {
structure(
rootId: "MQ=="
) {
items {
id
parent_id
entity {
... on CompanyTeam {
name
id
description
}
}
}
}
}
}
}
```

**Response:**

```json
{
"data": {
"updateCompanyStructure": {
"company": {
"structure": {
"items": [
{
"id": "MQ==",
"parent_id": "MA==",
"entity": {}
},
{
"id": "Mg==",
"parent_id": "MQ==",
"entity": {
"name": "Test Team",
"id": "MQ==",
"description": "Test Team description"
}
},
{
"id": "Mw==",
"parent_id": "Mg==",
"entity": {
"name": "Test Child Team",
"id": "Mg==",
"description": "Test Child Team dexription"
}
}
]
}
}
}
}
}
```

## Input attributes

The `CompanyStructureUpdateInput` input object defines the company team data.

### CompanyStructureUpdateInput attributes {#CompanyStructureUpdateInput}

The `CompanyStructureUpdateInput` object contains the following attributes:

Attribute | Data Type | Description
--- | --- | ---
`parent_tree_id` | ID! | The ID of a company that will be the new parent
`tree_id` | ID! | The ID of the company team that is being moved to another parent

You can get the `parent_tree_id` and `tree_id` with the [`company`]({{page.baseurl}}/graphql/queries/company.html) query.

## Output attributes

The `UpdateCompanyStructureOutput` output object contains the following attribute:

Attribute | Data Type | Description
--- | --- | ---
`company` | Company! | Contains company data

{% include graphql/company.md %}
Loading

0 comments on commit 2f1dd22

Please sign in to comment.