ShopifySharp: 2019-07 breaking change for pagination

It looks like the page parameter is not supported on some endpoints in version 2019-07.

See https://help.shopify.com/en/api/guides/paginated-rest-results

Might need to extract the new Link header and deprecate the page param for the affected endpoints.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 2
  • Comments: 58 (20 by maintainers)

Commits related to this issue

Most upvoted comments

I got the same thing! Publish is coming soon, I’m about halfway through rewriting all the list async methods. Then it’s just a matter of refactoring the tests and we should be good for at the very least a prerelease publish.

I’m going to be streaming my open source work – mostly on ShopifySharp – every Thursday at 2pm central US/3pm eastern US. I’ll probably stream it on Twitch for now, where I’ve done a few programming streams in the past.

Not trying to get internet famous or make that sweet streamer cash. I’m just going to use it as a way to ensure I’m making steady progress on this and my other projects each week, and maybe use it as a way to make the sometimes boring tedious work a tiny bit more interesting.

Edit from far in the future: streaming is buns and I’m way too busy to do that 😅

@nozzlegear I’ve pinged you an email.

Personally I would definitely recommend applying the [Obsolete] attribute very soon.

Some folks may not be aware that the deadline is coming quickly and a warning is not that annoying. I think it’s best to be safe otherwise apps will definitely break.

@nozzlegear I’ve spotted an issue on orders. The returning filter is encoded and gets pushed through encoded to the ‘new filter’ image

See code i’ve used which works in production right now: `
var hasNextPageResults = true; var page = 1;

        while (hasNextPageResults)
        {
            ListResult<Order> result = await service.ListAsync(listFilter);

            Console.WriteLine($"Received page {page}");
            if (result.LinkHeader?.NextLink != null)
            {
                var newFilter = result.LinkHeader.NextLink.GetFollowingPageFilter();
                // NOTE: For now, you must set the limit and fields property for further page filters manually.
                newFilter.Limit = filter.Limit;
                // Set the filter to the following page filter, which will grab the next page.
                // Failure to do this will result in an infinite loop as the Shopify API returns the first page over and over

                // bug with fields being encoded by shopify
                newFilter.Fields = newFilter.Fields.Replace("%2C", ",");

                listFilter = newFilter;
            }
            else
            {
                hasNextPageResults = false;
            }

            items.AddRange(result.Items);

            if (items.Count > maxOrdersToReturn)
                hasNextPageResults = false;
            page++;

        }`

Great! @nozzlegear have you seen my comment above ?

Given the breaking change for the collection service, my suggestion is to pin v5.0 to 2019-10. The paging change is fairly risky on its own. Implementing the collection service breaking change at the same time would increase risk even more.

We could release v6.0 pinned to 2020-01 shortly after, to implement the new collection API (and potentially the fulfillment orders API). What do you think?

I’m going to finish up the remaining work today on converting the services to use the new list API method. Fingers crossed, I’ll have a prerelease published on nuget either this evening or tomorrow, but it’s important to note that the tests are not running yet.

– Josh Harms

On Sun, Feb 23, 2020, at 04:10, Clement Gutel wrote:

I did get a couple of emails from Shopify regarding our use of deprecated calls but I think what @ctrl-d https://github.com/ctrl-d is saying is that his customers are getting emails too. This probably doesn’t inspire much confidence.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/nozzlegear/ShopifySharp/issues/380?email_source=notifications&email_token=AASOE7B3ITHWOKMW6UCPSN3REJDRXA5CNFSM4H6WZSE2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEMVXYUA#issuecomment-590052432, or unsubscribe https://github.com/notifications/unsubscribe-auth/AASOE7AN6CVSHR5JYABJVVLREJDRXANCNFSM4H6WZSEQ.

@clement911 Correct, what I wrote about the version was a little confusing! I’m planning to target version 2020-01, since 2020-04 will still be in the RC stage by the time I want to release v5 in the next couple of weeks.

Alright, I’ve pushed a branch to GitHub containing the first steps to releasing version 5.0! My goal for 5.0 is to update the API to target at least version 2020-01, update all of the ListAsync methods to use the new paginated listing scheme, and add interfaces for all services.

I’ve also published version 4.25.0 to nuget, which marks every existing ListAsync method as obsolete and warns developers using them that the method will cease to work after April 2020.

Thanks for the heads up on the smart collection! I’m going to be working on this tomorrow and will for sure push a pre-release package for 5.0.

Hi @nozzlegear , are you working on this issue by any chance?

The deprecation of 2019-04 is coming pretty quickly so it would be fantastic to move ShopifySharp to a new version. As far as I know, this is the biggest change that needs to be implemented.

https://help.shopify.com/en/api/versioning/release-notes

Ooo! Yeah you’re right! https://help.shopify.com/en/api/guides/paginated-rest-results states 7 services under Supported Endpoints, but the changelog https://help.shopify.com/en/api/versioning/release-notes/2019-07 has rather more than that.

That said, the majority of them are for XXXSavedSearch.

I went through and correlated the 2019-07 changelog vs the services that are implemented in ShopifySharp and found this

| 2019-07 (Cusor-based pagination) – | – AccessScope |   ApplicationCredit |   Article |   Asset |   Authorization |   Blog |   Carrier |   Charge |   Checkout |   Collect | YES CustomCollection |   Customer |   CustomerAddress |   CustomerSavedSearch | YES Discount |   DiscountCode |   DraftOrder |   Event | YES Fulfillment |   FulfillmentEvent |   FulfillmentService |   GiftCard |   Graph |   InventoryItem |   InventoryLevel |   Location |   MetaField | YES Order |   OrderRisk |   Page |   Policy |   PriceRule |   Product | YES ProductImage |   ProductVariant | YES RecurringCharge |   Redirect |   ScriptTag |   ShippingZone |   Shop |   ShopifyPayments |   SmartCollection |   Theme |   Transaction |   UsageCharge |   User |   Webhook |

Ie, 6 of the current services need cursor-based pagination implemented for 2019-07. Guess a broken clock is right twice a day after all.

Many of the rest of the existing services do have a ListAsync method though I haven’t counted them. A quick scan shows the first half dozen do have an implementation but will not get cursor-based pagination in 2019-07.

CustomCollection, Customer, Discounts, Order and SmartCollection would benefit from the IListAsync interface imo. It would certainly benefit me at least 😉

And yes, I should imagine IListAsync and IPageAsync would both be implemented on the applicable services.