I Have created a module to add custom attribute to createCustomer mutation.


<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Api/etc/extension_attributes.xsd">
<extension_attributes for="Magento\Customer\Api\Data\CustomerInterface">
    <attribute code="custom_attr" type="string"/>


<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="Magento\Customer\Api\Data\CustomerInterface">
        <argument name="extensionAttributesObjects" xsi:type="array">
            <item name="custom_attr" xsi:type="string">Vendor\Module\Api\Data\CustomerExtensionInterface</item>



namespace Vendor\Module\Api\Data;

interface CustomerExtensionInterface
 * Get customAttr
 * @return string|null
public function getCustomAttr(): ?string;

 * Set custom_attr
 * @param string|null $custom_attr
 * @return $this
 public function setCustomAttr(?string $custom_attr): self;

Now I am trying this request in createCustomer Mutattion

mutation {
    input: {
     firstname: "test"
     lastname: "test"
     email: "test@gmail.com.com"
     is_subscribed: true
     custom_attr: "test value"
 ) {
    customer {

Note: created the "custom_attr" customer attribute with data patch.

Getting below error

"message": "Field "custom_attr" is not defined by type CustomerInput.",

Can someone help me on this how to custom attribute in the create customer mutation in graphQL.

1 Answer 1


To extend existed GraphQL schema you need to redefine the needed type/interface/input like we do with XML schema in Magento.

First things first you should create the schema.graphqls file in your custom module under etc directory.

In this file you need to redefine the CustomerInput input type (your custom input option will be merged with already defined input options in Magento):

If you are using Magento version 2.4.6 please replace CustomerInput with CustomerCreateInput and for mutation use createCustomerV2

input CustomerInput {
    custom_attr: String

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.