Shopify Storefront API 2020-10 (latest) can't fetch quantityAvailable (GraphQL) - graphql

For the first time I'm working with Shopify Storefront API (v. 2020-10, latest) and trying out GraphQL (I'm used to REST).
I'm able to get all the products, but if I add the field "quantityAvailable" an error occur:
Field 'quantityAvailable' doesn't exist on type 'ProductVariant'
I'm following the docs where the field is listed,
can you help me understand what am I doing wrong?
Edit #1
I've already enabled "Read inventory of products and their variants" in Storefront API Permissions.
Edit #2
I'm sending a POST request to https://{my-shopify-website}/api/graphql attaching content-type and X-Shopify-Storefront-Access-Token as header

Using the /api/2020-10/graphql end-point allows the usage of quantityAvailable property, but using the unstable end-point /api/graphql doesn't.
This seems more like a Shopify docs or API bug/issue, but the solution is to use the specific version end-point (/api/2020-10/graphql) instead of the unstable one.

Related

Fetch Public App Details Using Shopify Storefront API

I have one scenario where I want to access third-party apps/public apps(shopthru) data using Shopify storefront API.
In my case, I am using shopthru app and I want to fetch data about the created campaign, campaign conditions (like discount for specific walletaddress, or POAP NFT).
I want to know if is it possible to get third party app / public app details using shopify storefront API.
This is not possible. Shopify Apps doesn't integrate and extend Shopify Storefront API. You can try to find out what URL of app is by inspecting iframe, pull out accesstoken from your request and using curl try to extract data but this is very hackish and unstable way.
Other option would be to contact App Developer and ask him to expose some endpoints.
If App is changing your store behavior, you can try to fetch data using GraphQL Admin API and find desired details in discounts object:
https://shopify.dev/apps/discounts/existing
https://shopify.dev/api/admin-graphql/2022-10/queries/codeDiscountNode

Shopify Graphql API - draftOrderCreate redirect to Checkout with Discount Code Field

If you are familiar with Shopify draftOrderCreate API, you know that when retrieving the invoice_url via the graphql mutation, it will redirect you to the checkout page but there will be no DISCOUNT CODE Field, and Shopify docs are clear with this, but upon checking some apps (https://apps.shopify.com/draft-helper) it is possible, but on the said app, you will manually generate the checkout link.
Here's a photo of what that app is doing
I am wondering how do i integrate this automatically via graphql. When checking the Console (Network) it seems like he is only passing the draft order id as payload.
When you create a Draft Order, you can provide a discount. So if you do that, and then send the invoice, the discount should be applied correctly.

My Google API keeps returning a limit reached error, when I am sure I am under the limit

I am currently building a NodeJS backend app that is querying the Google Calendar API. I have setup a new project on Google Cloud API platform and have generated all the required credentials. As stated by the google calendar API page, the allowed queries per day is 1,000,000. Since I am only querying for testing purposes at the moment, I am sure that I haven't even hit a 100. Yet whenever I try to query the API it returns the error:
"The API returned an error: Error: Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup."
Also I have noticed that the dev console has generated a API key for me. Where am I supposed to put that?
My initial thinking is that Google API requires me to perform an additional signup using some CLI tools or something along those lines to signup. If not, where am I supposed to sign up?
Thanks in advance.
Note: I already have all the information from the cloud platform such as client_id, client_secret, project_id.
In "Error: Daily Limit for Unauthenticated Use Exceeded", they key word is Unauthenticated. Your request to the Calendar API is missing an OAuth Access Token. You will need to research Google OAuth.
This question has been answered many times. Please learn how to search SO for similar questions whenever you post a new question. https://stackoverflow.com/search?q=google+oauth+%22daily+limit+for+unauthenticated%22
To anyone who comes across this post in the future. I fixed the issue by using the project generated by Google Calendar API site (https://developers.google.com/calendar/quickstart/nodejs) by clicked the big blue "Enable the google calendar api" and then changing the name of the quickstart project that was generated. I don't know why it works now but it does and it's been working quite stably so far. Lets see how to goes.

Dart googleapis 0.35.0 - Google Drive API v3 - fields request parameter

Google Drive API v3 documentation:
Full resources are no longer returned by default. Use the fields query parameter to request specific fields to be returned. If left unspecified only a subset of commonly used fields are returned.
Either there is a fields request (query) parameter in the googleapis Dart library (which I can't find) or the library is useless for Google Drive API v3. Or maybe a workaround?
Looks like the fields need to be added to the URL
https://github.com/dart-lang/googleapis/blob/571f592976b7cf557d94bd0fc61b412fc1087446/generated/googleapis/lib/drive/v3.dart#L87
https://developers.google.com/drive/v3/web/performance#partial
https://www.googleapis.com/demo/v1?key=YOUR-API-KEY&fields=kind,items(title,characteristics/length)
I believe it means that some HTTP requests (in the underlying web api) require a additional ?fields='...' parameter to know what fields to include in the response. That documentation page helpfully gives a list of fields but does not say which requests require the parameter.
I personally find neither the Google api pages nor the Dart Google API libraries documentation to be very helpful, however, the Google OAuth Playground allows all the apis to be executed and tested. I used this tool to figure out what inputs are required for each web request and to make sure my Dart code was getting expected results.
Edit:
Every request in the api MAY include a ?fields='...' parameter, but don't have to.
If left unspecified only a subset of commonly used fields are
returned.
So depending on what you are doing you may not need to specify it.

Getting the URL of a Mailchimp list via the API

I'd like to link directly to a Mailchimp list in the Mailchimp dashboard. I have full API access, and the list id is: bb7b537cd0.
However, I notice when looking at the dashboard URL that the URL is:
https://us5.admin.mailchimp.com/lists/members/?id=212269
The id 212269 is not present in the API response data about this list.
Is there any way of linking directly to the list that I'm not aware of?
Thanks!
This isn't possible through v3.0, but is possible in older versions. The main reason it was removed from 3.0 is that the dashboard URLs can change without notice, so relying on a particular algorithm to build them isn't advisable.

Resources