MagentoGraphqlClient | Community
Skip to main content
New Participant
November 9, 2022
Question

MagentoGraphqlClient

  • November 9, 2022
  • 4 replies
  • 3816 views

how to create MagentoGraphqlClient conection ?

in order to execute graphql queries to fetch products from magento

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

4 replies

New Participant
December 28, 2023

Any luck with this issue? I am having the same problem with my custom product component.

MagentoGraphqlClient is not getting injected in my CustomProductImpl even though I have all required OSGI configurations done. Due to this, I am getting magentoGraphqlClient object as null. I kept debug pointer in OOTB ProductImpl as well, and over there I can see the object is getting initialised. 


Strange thing, the injection in my local works fine some times and some times it doesn’t. In AEM cloud Dev ,magentoGraphqlClient is always null.

HeenaMadan
New Participant
December 28, 2023

Have you configured commerce endpoint in AEM cloud instance? If not, it will give you null magentoGraphql client

New Participant
December 28, 2023

yep, that's configured in cloud manager. All OSGI configs are also fine. 

all dependencies and embeds are done in pom files. 

HeenaMadan
New Participant
November 9, 2022

Add store/ url required details in OSGI config - com.adobe.cq.commerce.graphql.client.impl.GraphqlClientImpl~<identifier>.cfg.json

then create cloudconfig of the store view

  1. In AEM go to Tools -> Cloud Services -> CIF Configuration

  2. Select the commerce configuration you want to change

  3. Open the configuration properties via the action bar

and configure to site hierarchy

 

Refer detailed adobe doc https://experienceleague.adobe.com/docs/experience-manager-65/commerce/storefront/getting-started.html?lang=en#:~:text=In%20AEM%20go%20to%20Tools,properties%20via%20the%20action%20bar

backend side to get MagentoGraphqlClient object:

MagentoGraphqlClient magentoGraphQLclientObject = resource.adaptTo(MagentoGraphqlClientImpl.class): request.adaptTo(MagentoGraphqlClientImpl.class);  
New Participant
November 10, 2022

Hi Heena Madan,

Getting  build error while using 

MagentoGraphqlClient magentoGraphQLclientObject = resource.adaptTo(MagentoGraphqlClientImpl.class);

 

[ERROR] The analyser found the following errors for author and publish :
[ERROR] [api-regions-exportsimports] com.aem.magento:aem-magento.core:1.0.0-SNAPSHOT: Bundle aem-magento.core:1.0.0-SNAPSHOT is importing package(s) com.adobe.cq.commerce.core.components.internal.client in start level 20 but no bundle is exporting these for that start level. (com.aem.magento:aem-magento.all:1.0.0-SNAPSHOT)

 

I have used,

<dependency>
<artifactId>core-cif-components-core</artifactId>
<version>2.12.0</version>
<groupId>com.adobe.commerce.cif</groupId>
<scope>provided</scope>
</dependency>

 

HeenaMadan
New Participant
November 10, 2022

If bundle is not found at start level 20- you need to export these jars. embed required cif and magento jar in "all" module 

<!-- Adobe CIF Dependencies -->
                        <embedded>
                            <groupId>com.adobe.commerce.cif</groupId>
                            <artifactId>core-cif-components-apps</artifactId>
                            <type>zip</type>
                            <target>/apps/project-packages/application/install</target>
                        </embedded>
                        <embedded>
                            <groupId>com.adobe.commerce.cif</groupId>
                            <artifactId>core-cif-components-config</artifactId>
                            <type>zip</type>
                            <target>/apps/project-packages/application/install</target>
                        </embedded>
                        <embedded>
                            <groupId>com.adobe.commerce.cif</groupId>
                            <artifactId>core-cif-components-core</artifactId>
                            <target>/apps/project-packages/application/install</target>
                        </embedded>
                        <embedded>
                            <groupId>com.adobe.commerce.cif</groupId>
                            <artifactId>magento-graphql</artifactId>
                            <target>/apps/<project-packages/application/install</target>
                        </embedded>
                        <embedded>
                            <groupId>com.adobe.commerce.cif</groupId>
                            <artifactId>graphql-client</artifactId>
                            <target>/apps/project-packages/application/install</target>
                        </embedded>

 

krati_garg
Employee
November 9, 2022
Mani_kumar_
New Participant
November 9, 2022

This article from Adobe gives you pretty much everything to start to CIF integration with AEM

https://experienceleague.adobe.com/docs/experience-manager-65/commerce/storefront/getting-started.html?lang=en#:~:text=In%20AEM%20go%20to%20Tools,properties%20via%20the%20action%20bar

 

Make sure you have all the details of the Magento client like URL, username, password and root category to pick the catalog data

This will be a cloud configuration that needs to be added which is explained in detail in the article.