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 🙂
Be the first to comment.