Webkul
Services
Technologies Bagisto QloApps
iOS Android SAP BigCommerce Wix
Trusted by
Samsung Intel Toyota Walmart Disney Nokia Nestlé Decathlon
See all customers
Back to Top
DEV

How to Extend an existing GraphQL schema

In this article, We will learn about how to extend an existing GraphQL schema from our module.

First off, We will create a module.

Step-1: Define the configuration field in  etc/graphql/di.xml

<?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\StoreGraphQl\Model\Resolver\Store\StoreConfigDataProvider">
    <arguments>
      <argument name="extendedConfigData" xsi:type="array">
        <item name="section_group_field" xsi:type="string">section/group/field</item>
      </argument>
    </arguments>
  </type>
</config>

Step-2: Extend the type storeConfig in etc/schema.graphqls file.

type StoreConfig {
    section_group_field : String  @doc(description: "Extended Config Data - section/group/field")
}

Step-3: Write our custom query in ChromeiQl.

{
  storeConfig{
    section_group_field
  }
}

Hope this will help you.

Thanks 🙂

. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


Be the first to comment.

Back to Top

Message Sent!

If you have more details or questions, you can reply to the received confirmation email.

Back to Home