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










share|improve this question


























    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










    share|improve this question
























      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










      share|improve this question













      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






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 11 at 18:12









      takinola

      1,075719




      1,075719
























          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.






          share|improve this answer





















          • 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











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          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

























          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.






          share|improve this answer





















          • 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















          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.






          share|improve this answer





















          • 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













          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.






          share|improve this answer












          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.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          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


















          • 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


















          draft saved

          draft discarded




















































          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.




          draft saved


          draft discarded














          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





















































          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







          Popular posts from this blog

          Xamarin.iOS Cant Deploy on Iphone

          Glorious Revolution

          Dulmage-Mendelsohn matrix decomposition in Python