Can't Get Product Metafields using StoreFront GraphQL API - graphql

I am using storefront API for my Shopify store.
And need to retrieve product metafields for my product.
I already added metafields using 3rd party app(Metafields Guru).
I need to get all those metafields for product, and had been following this article.
https://shopify.dev/tutorials/retrieve-metafields-with-storefront-api
{
productByHandle(handle: "xxx-handle") {
id
title
handle
productType
metafields(first: 5) {
edges {
node {
key
value
}
}
}
}
}
But I get an empty array for metafields.
Not sure what I am missing here.
Any help would be appreciated

There are a couple of problems here.
when you created your metafields, you had to assign them to a namespace. When you try to retrieve them with Storefront API, you have to provide this namespace, and you failed to do that.
evem if you created metafields in the admin using some App, you will not see them using Storefront API unless you turn them ON using a special flag.
So that is likely a missed step too. Read up on this and pay attention to the MetafieldStorefrontVisibility. You set the namespace and key to be visible. Meaning you likely will not be creating metafields willy nilly without careful consideration about turning each one on or off to Storefront API access.

I would extend a bit David`s answer as I cannot add comments to other answers yet.
Indeed, you have to make the metafields explicitly visible to Storefront API by running mutation MetafieldStorefrontVisibility. Here are some useful links:
How to retrieve metafield from Shopify
How to use MetafieldStorefrontVisibility
Also, I found a nice app Accentuate Custom Fields that provides UI options for making metafields visible to the Storefront API while configuring the metafields:

Related

How to delete a Price Object using Stripe API Call

I am trying to delete a product using API call but it throws an error saying
"This product cannot be deleted because it has one or more user-created prices."
I checked in stripe documentation but there is no API for deleting the Price.
I recommend that you do not delete product and price objects; instead, archive them by marking them as inactive. You can do this by setting active to false on the Price or Product if you don't want to use them again.
Reference: https://pupuweb.com/solved-fix-stripe-payment-dev-error-delete-price/

How to read a Google People api response object [updated]

I'm new to Google's API and I'm having trouble reading the content of a People contact.
To get the details of a particular contact, references show this code should work [Edit: I updated the personfields]:
profile = service.people().get(resourceName='people/c63810788897573286', personFields='names')
The resourceName is the ID of a particular contact (that ID will only work for someone with access to my account). The server grabs it correctly and returns this:
<googleapiclient.discovery.Resource object at 0x10fd183c8>
How do I read the content of this object? I can't figure out from the documentation
I want to print out the Name. I'm pretty new to APIs, so maybe there is a standard way to read an HTTP object or maybe it's something unique to Google's API. Thanks for any advice
I found an answer in another somewhat related StackOverflow. I needed to the add .execute() to the call
profile = service.people().get(resourceName='people/c63810788897573286', personFields='names').execute()

Admin on rest add new resource to store dynamically

My project is structured like this.
As you can see there are three resources(posts, users, comments) defined.
So you cannot perform CRUD operations on any other resource. I am not using any custom clients (using aor-loopback rest client)
I would like to dynamically add new resources to the store so that I can access those tables/models/resources for CRUD. I know its possible (but don't know how), because we can update the store on the fly. Any help is appreciated.
I found the solution my problem. Sharing it for anyone who encounters the same.
import { DECLARE_RESOURCES } from 'admin-on-rest';
and use this action to re-initialise all the resources with an additional one.
Cheers.

New type for the deprecated grocery_or_supermarket type in google-places-API

Looks like google has deprecated a bunch of place types from their places API:
https://developers.google.com/places/web-service/supported_types
"The following types are deprecated, and will continue to be supported until February 16, 2017: establishment, finance, food, general_contractor, grocery_or_supermarket, health, place_of_worship."
I wasn't able to figure out what the new replacement types would be. "food" and "store" are too generic for a grocery related store.
Additionally, the documentation states that these types are deprecated only for the query API. The place-details results "may" still contain them.
A workaround I can implement is to fetch the places using a more generic type (e.g., store), and then filter on my end.. not ideal, but out of ideas. However, this also means that I'll rely on the more granular type (e.g., grocery_or_supermarket) to be mentioned in the response.
Can someone pls comment or share ideas on this issue? (did any of you have to deal with this? would be great if you can share your thoughts)
Thanks
Use Foursquare API for this data instead of Google, just get a Foursquare API key, check the API how to use details online and that should provide the data your need.

Spring social and facebook api 2.4

I'm using spring-social for facebook, <version>2.0.1.RELEASE</version> and it works fine if I use the 2.3 Facebook version API.
I create a new app with the version 2.4 and it doesn’t work correctly, since FB changed the API policies:
https://developers.facebook.com/blog/post/2015/07/08/graph-api-v2.4/
Fewer default fields for faster performance:
To help improve
performance on mobile network connections, we've reduced the number of
fields that the API returns by default. You should now use the
?fields=field1,field2 syntax to declare all the fields you want the
API to return.
For example the post contains only the id and message and not from-name and from-id, so the class Post contains only this two fields.
Now to read this value we need to add “?fields=from”.
The question is, is there a way to use spring social also with the version 2.4 ?
It seems that the problem persists. So, I am using as workaround the following method to bring back the fields I need:
Facebook facebook = new FacebookTemplate(accessToken);
Post post = facebook.fetchObject(postId, Post.class, "picture, message, source, story, caption, place, description, type, from, link, icon, shares, created_time, name");

Resources