Discuss all the new features introduced with the new product model in GraphQL.
Let us assume that our use case is this:
A merchant wishes to export all of their Shopify products into a products list (XLSX file, CSV, XML or otherwise).
Up until now, an app that used the REST API to fetch all products from the store, using link based pagination, managed to do the trick for most of the products' data, as well as their variants, options and images.
If the app now must migrate from the REST API to GraphQL, what would the fetching logic need to be in order to match the effectiveness of the REST API?
Comparatively, fetching all products with REST and link based pagination is quicker than fetching them with GraphQL and cursor based pagination.
Would apps like that need to resort to bulk operation queries for use cases such as these?
Solved! Go to the solution
This is an accepted solution.
Hey @StefanosDev,
We went through a similar thought process when migrating our Bulk Product Editor app to use the GraphQL API. There's pros/cons to both the cursor-based pagination and bulk operation queries but I'd probably lean towards using the bulk operation queries if you just export all the product data.
Using the cursor-based pagination gives you more visibility into the progress of the job but depending on the number of related resources (variants, images, inventory items, metafields etc..) and page size you might need to do nested paginations for those records.
One problem with the bulk operations though is you can only have one running at a time on the store. If you're only using the API to download the products though it shouldn't be an issue.
As far as speed goes, I don't haven't a direct comparison but I feel like the bulk operations are faster on average but there's a higher variance in the time it takes to complete.
All that to say, I'd recommend trying the bulk operations first and see if that works for you. If there is a case where it's not working, or it's randomly too slow, you'll still be able to reuse a lot of the GraphQL query for your pagination.
Also, if you're just getting started with the GraphQL API, there's an AI assistant for it in the docs. Just go to https://shopify.dev/docs/api/admin-graphql , click on the search bar and then on 'Open Assistant'. It's not perfect but does help give an idea of how to structure some of the queries.
I hope this helps! Best,
Daniel
This is an accepted solution.
Hey @StefanosDev,
We went through a similar thought process when migrating our Bulk Product Editor app to use the GraphQL API. There's pros/cons to both the cursor-based pagination and bulk operation queries but I'd probably lean towards using the bulk operation queries if you just export all the product data.
Using the cursor-based pagination gives you more visibility into the progress of the job but depending on the number of related resources (variants, images, inventory items, metafields etc..) and page size you might need to do nested paginations for those records.
One problem with the bulk operations though is you can only have one running at a time on the store. If you're only using the API to download the products though it shouldn't be an issue.
As far as speed goes, I don't haven't a direct comparison but I feel like the bulk operations are faster on average but there's a higher variance in the time it takes to complete.
All that to say, I'd recommend trying the bulk operations first and see if that works for you. If there is a case where it's not working, or it's randomly too slow, you'll still be able to reuse a lot of the GraphQL query for your pagination.
Also, if you're just getting started with the GraphQL API, there's an AI assistant for it in the docs. Just go to https://shopify.dev/docs/api/admin-graphql , click on the search bar and then on 'Open Assistant'. It's not perfect but does help give an idea of how to structure some of the queries.
I hope this helps! Best,
Daniel