Does Shopify Ajax API support Graphql?
up vote
0
down vote
favorite
I would like to manipulate the cart based on tags on products in the cart. I'm currently using the Shopify Ajax API to retrieve the cart contents and then the products in the cart. This leads to performance issues given the number of calls required. This is a classic issue addressed by GraphQL so I'm wondering if there is a solution available
graphql shopify shopify-app
add a comment |
up vote
0
down vote
favorite
I would like to manipulate the cart based on tags on products in the cart. I'm currently using the Shopify Ajax API to retrieve the cart contents and then the products in the cart. This leads to performance issues given the number of calls required. This is a classic issue addressed by GraphQL so I'm wondering if there is a solution available
graphql shopify shopify-app
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I would like to manipulate the cart based on tags on products in the cart. I'm currently using the Shopify Ajax API to retrieve the cart contents and then the products in the cart. This leads to performance issues given the number of calls required. This is a classic issue addressed by GraphQL so I'm wondering if there is a solution available
graphql shopify shopify-app
I would like to manipulate the cart based on tags on products in the cart. I'm currently using the Shopify Ajax API to retrieve the cart contents and then the products in the cart. This leads to performance issues given the number of calls required. This is a classic issue addressed by GraphQL so I'm wondering if there is a solution available
graphql shopify shopify-app
graphql shopify shopify-app
asked Nov 11 at 18:12
takinola
1,075719
1,075719
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
How is making a call to the cart endpoint and getting back the contents a performance issue? Have you thought through what you are trying to do? If you do a single call to the cart, you get all the products in the cart. If you want to manipulate the products in the cart, what does that mean? If you are saying, geez, I need to see the tags of each product, and you then do an ajax call per product to get the tags, you are doing it wrong. Instead, when you place a product in the cart, add the special tag as a line item property. That way, when you want to play with the cart, you have all the data at your fingertips.
This is not a "classic GraphQL" kind of thing in my opinion, but instead, a question of perhaps not adopting the cleanest, fastest pattern of the many you could choose to use.
What I'm trying to do is surface some functionality in the cart only if there is at least one product with a certain tag eg show super-duper offer only if customer has selected at least one product tagged "exclusive". This requires n+1 API calls for n products in the cart. This can take a while given Shopify loads script_tags last and the customer may be on a slow network connection. Hope this clarifies the issue
– takinola
Nov 11 at 18:24
Read my answer. I showed you that you DO NOT need to make N+1 API calls. One will do. Iterate the cart. Examine the properties object of each product. If the tag you are looking for is there, do your thing.
– David Lazar
Nov 11 at 23:07
If I understand correctly, you are suggesting to insert the flag in the line item properties instead of the tag since the latter is returned when with the ajax api call for the cart. This seems like a reasonable approach but I am not sure how to include the required information in the line items properties. The Shopify API reference (help.shopify.com/en/themes/customization/products/features/…) is geared towards using this to capture customization information supplied by the customer and not pre-defined values.
– takinola
Nov 11 at 23:31
Whe you render a product in Liquid, you have the tags. So when you add that product to the cart, add the tag of interest as a line item property. You are free to use line item properties for any internal use you want, they are not only for customer monograms etc! They are perfect for this use case.
– David Lazar
Nov 12 at 3:07
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
How is making a call to the cart endpoint and getting back the contents a performance issue? Have you thought through what you are trying to do? If you do a single call to the cart, you get all the products in the cart. If you want to manipulate the products in the cart, what does that mean? If you are saying, geez, I need to see the tags of each product, and you then do an ajax call per product to get the tags, you are doing it wrong. Instead, when you place a product in the cart, add the special tag as a line item property. That way, when you want to play with the cart, you have all the data at your fingertips.
This is not a "classic GraphQL" kind of thing in my opinion, but instead, a question of perhaps not adopting the cleanest, fastest pattern of the many you could choose to use.
What I'm trying to do is surface some functionality in the cart only if there is at least one product with a certain tag eg show super-duper offer only if customer has selected at least one product tagged "exclusive". This requires n+1 API calls for n products in the cart. This can take a while given Shopify loads script_tags last and the customer may be on a slow network connection. Hope this clarifies the issue
– takinola
Nov 11 at 18:24
Read my answer. I showed you that you DO NOT need to make N+1 API calls. One will do. Iterate the cart. Examine the properties object of each product. If the tag you are looking for is there, do your thing.
– David Lazar
Nov 11 at 23:07
If I understand correctly, you are suggesting to insert the flag in the line item properties instead of the tag since the latter is returned when with the ajax api call for the cart. This seems like a reasonable approach but I am not sure how to include the required information in the line items properties. The Shopify API reference (help.shopify.com/en/themes/customization/products/features/…) is geared towards using this to capture customization information supplied by the customer and not pre-defined values.
– takinola
Nov 11 at 23:31
Whe you render a product in Liquid, you have the tags. So when you add that product to the cart, add the tag of interest as a line item property. You are free to use line item properties for any internal use you want, they are not only for customer monograms etc! They are perfect for this use case.
– David Lazar
Nov 12 at 3:07
add a comment |
up vote
0
down vote
How is making a call to the cart endpoint and getting back the contents a performance issue? Have you thought through what you are trying to do? If you do a single call to the cart, you get all the products in the cart. If you want to manipulate the products in the cart, what does that mean? If you are saying, geez, I need to see the tags of each product, and you then do an ajax call per product to get the tags, you are doing it wrong. Instead, when you place a product in the cart, add the special tag as a line item property. That way, when you want to play with the cart, you have all the data at your fingertips.
This is not a "classic GraphQL" kind of thing in my opinion, but instead, a question of perhaps not adopting the cleanest, fastest pattern of the many you could choose to use.
What I'm trying to do is surface some functionality in the cart only if there is at least one product with a certain tag eg show super-duper offer only if customer has selected at least one product tagged "exclusive". This requires n+1 API calls for n products in the cart. This can take a while given Shopify loads script_tags last and the customer may be on a slow network connection. Hope this clarifies the issue
– takinola
Nov 11 at 18:24
Read my answer. I showed you that you DO NOT need to make N+1 API calls. One will do. Iterate the cart. Examine the properties object of each product. If the tag you are looking for is there, do your thing.
– David Lazar
Nov 11 at 23:07
If I understand correctly, you are suggesting to insert the flag in the line item properties instead of the tag since the latter is returned when with the ajax api call for the cart. This seems like a reasonable approach but I am not sure how to include the required information in the line items properties. The Shopify API reference (help.shopify.com/en/themes/customization/products/features/…) is geared towards using this to capture customization information supplied by the customer and not pre-defined values.
– takinola
Nov 11 at 23:31
Whe you render a product in Liquid, you have the tags. So when you add that product to the cart, add the tag of interest as a line item property. You are free to use line item properties for any internal use you want, they are not only for customer monograms etc! They are perfect for this use case.
– David Lazar
Nov 12 at 3:07
add a comment |
up vote
0
down vote
up vote
0
down vote
How is making a call to the cart endpoint and getting back the contents a performance issue? Have you thought through what you are trying to do? If you do a single call to the cart, you get all the products in the cart. If you want to manipulate the products in the cart, what does that mean? If you are saying, geez, I need to see the tags of each product, and you then do an ajax call per product to get the tags, you are doing it wrong. Instead, when you place a product in the cart, add the special tag as a line item property. That way, when you want to play with the cart, you have all the data at your fingertips.
This is not a "classic GraphQL" kind of thing in my opinion, but instead, a question of perhaps not adopting the cleanest, fastest pattern of the many you could choose to use.
How is making a call to the cart endpoint and getting back the contents a performance issue? Have you thought through what you are trying to do? If you do a single call to the cart, you get all the products in the cart. If you want to manipulate the products in the cart, what does that mean? If you are saying, geez, I need to see the tags of each product, and you then do an ajax call per product to get the tags, you are doing it wrong. Instead, when you place a product in the cart, add the special tag as a line item property. That way, when you want to play with the cart, you have all the data at your fingertips.
This is not a "classic GraphQL" kind of thing in my opinion, but instead, a question of perhaps not adopting the cleanest, fastest pattern of the many you could choose to use.
answered Nov 11 at 18:19
David Lazar
5,37831426
5,37831426
What I'm trying to do is surface some functionality in the cart only if there is at least one product with a certain tag eg show super-duper offer only if customer has selected at least one product tagged "exclusive". This requires n+1 API calls for n products in the cart. This can take a while given Shopify loads script_tags last and the customer may be on a slow network connection. Hope this clarifies the issue
– takinola
Nov 11 at 18:24
Read my answer. I showed you that you DO NOT need to make N+1 API calls. One will do. Iterate the cart. Examine the properties object of each product. If the tag you are looking for is there, do your thing.
– David Lazar
Nov 11 at 23:07
If I understand correctly, you are suggesting to insert the flag in the line item properties instead of the tag since the latter is returned when with the ajax api call for the cart. This seems like a reasonable approach but I am not sure how to include the required information in the line items properties. The Shopify API reference (help.shopify.com/en/themes/customization/products/features/…) is geared towards using this to capture customization information supplied by the customer and not pre-defined values.
– takinola
Nov 11 at 23:31
Whe you render a product in Liquid, you have the tags. So when you add that product to the cart, add the tag of interest as a line item property. You are free to use line item properties for any internal use you want, they are not only for customer monograms etc! They are perfect for this use case.
– David Lazar
Nov 12 at 3:07
add a comment |
What I'm trying to do is surface some functionality in the cart only if there is at least one product with a certain tag eg show super-duper offer only if customer has selected at least one product tagged "exclusive". This requires n+1 API calls for n products in the cart. This can take a while given Shopify loads script_tags last and the customer may be on a slow network connection. Hope this clarifies the issue
– takinola
Nov 11 at 18:24
Read my answer. I showed you that you DO NOT need to make N+1 API calls. One will do. Iterate the cart. Examine the properties object of each product. If the tag you are looking for is there, do your thing.
– David Lazar
Nov 11 at 23:07
If I understand correctly, you are suggesting to insert the flag in the line item properties instead of the tag since the latter is returned when with the ajax api call for the cart. This seems like a reasonable approach but I am not sure how to include the required information in the line items properties. The Shopify API reference (help.shopify.com/en/themes/customization/products/features/…) is geared towards using this to capture customization information supplied by the customer and not pre-defined values.
– takinola
Nov 11 at 23:31
Whe you render a product in Liquid, you have the tags. So when you add that product to the cart, add the tag of interest as a line item property. You are free to use line item properties for any internal use you want, they are not only for customer monograms etc! They are perfect for this use case.
– David Lazar
Nov 12 at 3:07
What I'm trying to do is surface some functionality in the cart only if there is at least one product with a certain tag eg show super-duper offer only if customer has selected at least one product tagged "exclusive". This requires n+1 API calls for n products in the cart. This can take a while given Shopify loads script_tags last and the customer may be on a slow network connection. Hope this clarifies the issue
– takinola
Nov 11 at 18:24
What I'm trying to do is surface some functionality in the cart only if there is at least one product with a certain tag eg show super-duper offer only if customer has selected at least one product tagged "exclusive". This requires n+1 API calls for n products in the cart. This can take a while given Shopify loads script_tags last and the customer may be on a slow network connection. Hope this clarifies the issue
– takinola
Nov 11 at 18:24
Read my answer. I showed you that you DO NOT need to make N+1 API calls. One will do. Iterate the cart. Examine the properties object of each product. If the tag you are looking for is there, do your thing.
– David Lazar
Nov 11 at 23:07
Read my answer. I showed you that you DO NOT need to make N+1 API calls. One will do. Iterate the cart. Examine the properties object of each product. If the tag you are looking for is there, do your thing.
– David Lazar
Nov 11 at 23:07
If I understand correctly, you are suggesting to insert the flag in the line item properties instead of the tag since the latter is returned when with the ajax api call for the cart. This seems like a reasonable approach but I am not sure how to include the required information in the line items properties. The Shopify API reference (help.shopify.com/en/themes/customization/products/features/…) is geared towards using this to capture customization information supplied by the customer and not pre-defined values.
– takinola
Nov 11 at 23:31
If I understand correctly, you are suggesting to insert the flag in the line item properties instead of the tag since the latter is returned when with the ajax api call for the cart. This seems like a reasonable approach but I am not sure how to include the required information in the line items properties. The Shopify API reference (help.shopify.com/en/themes/customization/products/features/…) is geared towards using this to capture customization information supplied by the customer and not pre-defined values.
– takinola
Nov 11 at 23:31
Whe you render a product in Liquid, you have the tags. So when you add that product to the cart, add the tag of interest as a line item property. You are free to use line item properties for any internal use you want, they are not only for customer monograms etc! They are perfect for this use case.
– David Lazar
Nov 12 at 3:07
Whe you render a product in Liquid, you have the tags. So when you add that product to the cart, add the tag of interest as a line item property. You are free to use line item properties for any internal use you want, they are not only for customer monograms etc! They are perfect for this use case.
– David Lazar
Nov 12 at 3:07
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53251722%2fdoes-shopify-ajax-api-support-graphql%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown