A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
I have an app that will (via private proxy app using the shopify rails app) send an email to the logged in customer to update the customers payment method (useful for customers who have had their card change, roll over or have new expiration date). It works.
However, can the response sometimes include an empty array for payment methods (looking to exception handle)::
"paymentMethods"=>{"edges"=>[{"node"=>{"id"=>"gid://shopify/CustomerPaymentMethod/abcde123etc"}}]}}}
If I need to exception handle that's fine, I can't see any info where the payment method could be an empty array if say the card was declined repeatedly, or if the card was canceled, etc. Just trying to cover the bases here as this is a background job.
Solved! Go to the solution
This is an accepted solution.
Hi @fwallace,
The Customer.paymentMethods connection returns a non-nullable array, which would be expected to be empty if the customer has no associated CustomerPaymentMethods.
If you are querying every customer as they log in then I would definitely recommend handling empty arrays.
Hope that helps!
- James
Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
This is an accepted solution.
Hi @fwallace,
The Customer.paymentMethods connection returns a non-nullable array, which would be expected to be empty if the customer has no associated CustomerPaymentMethods.
If you are querying every customer as they log in then I would definitely recommend handling empty arrays.
Hope that helps!
- James
Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog