diff --git a/vendor/magento/module-company-graph-ql/Model/Resolver/Customer/CustomerId.php b/vendor/magento/module-company-graph-ql/Model/Resolver/Customer/CustomerId.php new file mode 100644 index 000000000000..b6ee17bf2e4b --- /dev/null +++ b/vendor/magento/module-company-graph-ql/Model/Resolver/Customer/CustomerId.php @@ -0,0 +1,72 @@ +resolverAccess->isAllowed($this->allowedResources); + } catch (\Exception $e) { + // If user is not company user, then return null + return null; + } + + if ($field->getName() === 'id') { + $customerId = $value['model']->getId(); + return $customerId ? $this->uidEncoder->encode((string)$customerId) : null; + } + return null; + } +} diff --git a/vendor/magento/module-company-graph-ql/etc/graphql/di.xml b/vendor/magento/module-company-graph-ql/etc/graphql/di.xml index 89a4774ea702..9fd47ca98535 100644 --- a/vendor/magento/module-company-graph-ql/etc/graphql/di.xml +++ b/vendor/magento/module-company-graph-ql/etc/graphql/di.xml @@ -170,6 +170,13 @@ CompaniesSorting + + + + Magento_Company::users_view + + + diff --git a/vendor/magento/module-company-graph-ql/etc/schema.graphqls b/vendor/magento/module-company-graph-ql/etc/schema.graphqls index 07365409ca88..32d0bfb16171 100644 --- a/vendor/magento/module-company-graph-ql/etc/schema.graphqls +++ b/vendor/magento/module-company-graph-ql/etc/schema.graphqls @@ -130,7 +130,7 @@ type CompanyStructure @doc(description: "Contains an array of the individual nod } type CompanyTeam @doc(description: "Describes a company team.") { - id: ID! @doc(description: "The unique ID for a `CompanyTeam` object.") + id: ID @doc(description: "The unique ID for a `CompanyTeam` object.") name: String @doc(description: "The display name of the team.") description: String @doc(description: "An optional description of the team.") structure_id: ID! @doc(description: "ID of the company structure") @@ -325,6 +325,7 @@ type Customer { status: CompanyUserStatusEnum @resolver(class: "Magento\\CompanyGraphQl\\Model\\Resolver\\Company\\Customer\\Customer") @doc(description: "Indicates whether the company user is ACTIVE or INACTIVE.") structure_id: ID! @resolver(class: "Magento\\CompanyGraphQl\\Model\\Resolver\\Company\\Customer\\StructureId") @doc(description: "ID of the company structure") companies(input: UserCompaniesInput): UserCompaniesOutput! @doc(description: "An object that contains a list of companies user is assigned to.") @resolver(class:"Magento\\CompanyGraphQl\\Model\\Resolver\\Customer\\Companies") + id: ID @resolver(class: "Magento\\CompanyGraphQl\\Model\\Resolver\\Customer\\CustomerId") @doc(description: "The ID assigned to the customer.") } input UserCompaniesInput @doc(description: "Defines the input for returning matching companies the customer is assigned to.") {