I am developing my first shopify application.
It’s embedded shopify application.
In order to reduce server operation as much as possible, we are considering using shopify’s metafield as a storage area for application data instead of our own database. By using metafields, we aim to display the necessary information to the user without accessing the server when the user accesses the site.
So I would like to know if there is almost always a meta field available from our app.
Specifically, we would like to know what the behavior will be if our app sends a POST request when the metafield is already being used up to the maximum value (200 or 250) by another apps or merchant.
- For our application, it is also possible to use 20 metafields for one shopify resource.
- Each metafield will contain a value of type json.
I look forward to hearing from you.
It seems like you are looking at it the wrong way around.
metafields are stored on the Shopify servers. To access them, you need to make an API call. The fact that your app is an embedded app, does not change this. (‘non embedded’/‘embedded’ only has to do with where your app’s UI is shown).
Since the Shopify API is rate limited, it is usually better to store the data you need in your own database. Access to your own database instance is not rate limited, and typically a lot quicker too.
From a more abstract software development perspective: storing data in places that were typically not intended for your use-case, is generally speaking not a good idea. It might seem like a good solution now, but it will almost always come back to hurt you somewhere in the future.
Dear Jacco-V,
Thank you for your response. I appreciate not only your specific solutions to the problem at hand, but also your advice on abstract software design considerations.
Regarding my previous inquiry, I would like to provide additional information about the premises and requirements that I may have omitted. Please let me know if any of the premises are incorrect.
Premises:
- The store data stored in metafields can be displayed on the Shopify site without API calls.
{% for file in product.metafields.custom.xxxxx.value %}
- The long-term availability of the software is not a concern
- as I am planning to implement it as a prototype, I am not considering the software’s instability due to design changes on Shopify’s side
- The rate limit of the Shopify API is not a consideration
- I plan to create my own database for real-time data and use asynchronous processing where necessary
Requirements:
- I want to use metafields as a storage area to enable Liquid templates to be displayed when a user accesses them
- By doing so, users can display data without accessing our servers when they access them.
Questions:
- If all metafields (200 or 250) were being used by the merchant or other apps, I would like to know what behavior the Shopify API would exhibit if a post request for a metafield was sent
- Will it be possible to create more than the upper limit once, or will an error be returned? If an error is returned, what kind of error will it be?
Thank you and I look forward to your response.