Shopify / mobile-buy-sdk-ios

Shopify’s Mobile Buy SDK makes it simple to sell physical products inside your mobile app. With a few lines of code, you can connect your app with the Shopify platform and let your users buy your products using Apple Pay or their credit card.
MIT License
452 stars 199 forks source link

Unable to fetch LineItems from order history. #949

Closed arun-wrg closed 5 years ago

arun-wrg commented 5 years ago

Mobile-Buy-SDK 3.2 Hello, I am getting a consistent error while trying to fetch the LineItems from order history. The query is providing all the other details correctly, but when I include the LineItems in that, it responds with an empty node.

This is the buildQuery with lineItem

       Storefront.buildQuery { $0
       .customer(customerAccessToken: SFAuthManager.authToken!) { $0
           .orders(first: 10) { $0
               .edges { $0
                   .node { $0
                       .id()
                       .orderNumber()
                       .totalPrice()
                       .lineItems{ $0
                           .edges{ $0
                               .node{ $0
                                   .title()
                                   .quantity()
                                   .variant{ $0
                                       .id()
                                       .price()
                                       .title()
                                       .image{ $0
                                           .originalSrc()
                                       }
                                   }
                               }
                           }
                       }
                   }
               }
           }
       }
   } `

This is the response I am getting [“customer”: <null>]

Please note that if I am using the same buildQuery without lineItem it works perfectly. Below I am posting the code and its response.

       Storefront.buildQuery { $0
       .customer(customerAccessToken: SFAuthManager.authToken!) { $0
           .orders(first: 10) { $0
               .edges { $0
                   .node { $0
                       .id()
                       .orderNumber()
                       .totalPrice()
                   }
               }
           }
       }
   }`
customer: {
   orders =     {
       edges =         (
                       {
               node =                 {
                   id = “Z2lkOi8vc2hvcGlmeS9PcmRlci8yODYxOTU5NDEzODU/a2V5PTZkYzMzYjBkZDdhOTlkOTM3YzY1NTA4ODcyYWI4ZjE3";
                   orderNumber = 1008;
                   totalPrice = “0.00”;
               };
           },
                       {
               node =                 {
                   id = “Z2lkOi8vc2hvcGlmeS9PcmRlci84MDcyMTYyMTgxOTE/a2V5PTdiNDU1ODIzNjY0NmU1MDRkNzVjMWEyYmIwNTliMWYy”;
                   orderNumber = 1009;
                   totalPrice = “0.00”;
               };
           }
       );
   };
}
dbart01 commented 5 years ago

You have an error in your query. The field lineItems is paginated and requires at least one argument (e.g. first: 10).

arun-wrg commented 5 years ago

Thank you @dbart01. You saved my day!!