From 2f1dd2240508d0b4246e6d25c72364cdbf4da800 Mon Sep 17 00:00:00 2001 From: Andrii Beziazychnyi Date: Fri, 16 Oct 2020 06:45:58 +0300 Subject: [PATCH] ISSUE-7987: The GraphQL topic "Company team mutations" has been created (#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 --- src/_data/toc/graphql.yml | 20 +++ src/_includes/graphql/company-team.md | 7 + .../graphql/mutations/create-company-team.md | 127 ++++++++++++++++++ .../graphql/mutations/delete-company-team.md | 61 +++++++++ .../mutations/update-company-structure.md | 121 +++++++++++++++++ .../graphql/mutations/update-company-team.md | 89 ++++++++++++ 6 files changed, 425 insertions(+) create mode 100644 src/_includes/graphql/company-team.md create mode 100644 src/guides/v2.4/graphql/mutations/create-company-team.md create mode 100644 src/guides/v2.4/graphql/mutations/delete-company-team.md create mode 100644 src/guides/v2.4/graphql/mutations/update-company-structure.md create mode 100644 src/guides/v2.4/graphql/mutations/update-company-team.md diff --git a/src/_data/toc/graphql.yml b/src/_data/toc/graphql.yml index 48f14ae9e9a..839b454eb9b 100644 --- a/src/_data/toc/graphql.yml +++ b/src/_data/toc/graphql.yml @@ -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 @@ -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 @@ -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 diff --git a/src/_includes/graphql/company-team.md b/src/_includes/graphql/company-team.md new file mode 100644 index 00000000000..74b6616d0c7 --- /dev/null +++ b/src/_includes/graphql/company-team.md @@ -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 diff --git a/src/guides/v2.4/graphql/mutations/create-company-team.md b/src/guides/v2.4/graphql/mutations/create-company-team.md new file mode 100644 index 00000000000..77f6ea7cc78 --- /dev/null +++ b/src/guides/v2.4/graphql/mutations/create-company-team.md @@ -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 %} diff --git a/src/guides/v2.4/graphql/mutations/delete-company-team.md b/src/guides/v2.4/graphql/mutations/delete-company-team.md new file mode 100644 index 00000000000..422a709f07b --- /dev/null +++ b/src/guides/v2.4/graphql/mutations/delete-company-team.md @@ -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. diff --git a/src/guides/v2.4/graphql/mutations/update-company-structure.md b/src/guides/v2.4/graphql/mutations/update-company-structure.md new file mode 100644 index 00000000000..2224b530eeb --- /dev/null +++ b/src/guides/v2.4/graphql/mutations/update-company-structure.md @@ -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 %} diff --git a/src/guides/v2.4/graphql/mutations/update-company-team.md b/src/guides/v2.4/graphql/mutations/update-company-team.md new file mode 100644 index 00000000000..342640212c6 --- /dev/null +++ b/src/guides/v2.4/graphql/mutations/update-company-team.md @@ -0,0 +1,89 @@ +--- +group: graphql +title: updateCompanyTeam mutation +contributor_name: Atwix +contributor_link: https://www.atwix.com/ +b2b_only: true +--- + +Use the `updateCompanyTeam` mutation to update the company team data. + +## Syntax + +```graphql +mutation { + updateCompanyTeam( + input: CompanyTeamUpdateInput! + ) { + UpdateCompanyTeamOutput + } +} +``` + +## Example usage + +The following example updates the name and description of a company team. + +**Request:** + +```graphql +mutation { + updateCompanyTeam( + input: { + name: "My Test Team" + description: "My Test Team description" + id: "MQ==" + } + ) { + team { + id + name + description + } + } +} +``` + +**Response:** + +```json +{ + "data": { + "updateCompanyTeam": { + "team": { + "id": "MQ==", + "name": "My Test Team", + "description": "My Test Team description" + } + } + } +} +``` + +## Input attributes + +The `CompanyTeamUpdateInput` input object defines the company team data. + +### CompanyTeamUpdateInput attributes {#CompanyTeamUpdateInput} + +The `CompanyTeamUpdateInput` object contains the following attributes: + +Attribute | Data Type | Description +--- | --- | --- +`description` | String | An optional description of the team +`id` | ID! | The encoded team ID for updating +`name` | String | The display name of the team + +You can get the team ID with the [`company`]({{page.baseurl}}/graphql/queries/company.html) query. + +## Output attributes + +The `UpdateCompanyTeamOutput` output object contains the following attribute: + +Attribute | Data Type | Description +--- | --- | --- +`team` | CompanyTeam! | Contains company team data + +### CompanyTeam attributes {#CompanyTeam} + +{% include graphql/company-team.md %}