Hello Magento Friends,

In today’s Magento 2 tutorial, I am going to demonstrate How to Get Custom Column Value of Invoice and Credit Memo using GraphQL in Magento 2.

Adding custom columns to the invoice and credit memo tables in the Magento 2 database can be useful for storing information about orders, products, or customers that are not included in the standard Magento 2 database schema. For example, you might want to add a custom column to the invoice table to store information about a specific product that was included in an order, or a custom column to the credit memo table to store information about a refund that was issued for a specific order.

You can use the Magento 2 GraphQL API to retrieve the values of those custom columns for a specific invoice or credit memo. Let’s find out how

Steps to Get Custom Column Value of Invoice and Credit Memo using GraphQL in Magento 2:

Step 1: First, we need to create a “schema.graphqls” file inside etc folder

app\code\Vendor\Extension\etc\

Then add the code as follows

Step 2: After that, create “Invoices.php” file inside Resolver folder

app\code\Vendor\Extension\Model\Resolver\

And include the below-mentioned code

Step 3: After that, create “CreditMemos.php” file inside Resolver folder

app\code\Vendor\Extension\Model\Resolver\

Then include the following code

Step 4: Finally, run the upgrade and compile commands, then pass the query like below in the server

For Invoice:

For Creditmemo:

Output:

For Invoice:

invoice

Credit memo:

credit memo

Conclusion:

In this blog post, we have walked you through the process of using the Magento 2 GraphQL API to retrieve the values of those custom columns for a specific invoice or credit memo.

Related Article,

Magento 2: How to Get Custom Column Value of Order using GraphQL

If you have any questions or need further assistance, please feel free to contact us. We are always happy to help!

Happy Coding!

Click to rate this post!
[Total: 1 Average: 5]