Dedicated to the Hydrogen framework, headless commerce, and building custom storefronts using the Storefront API.
Our app has encountered an error while attempting to connect to the API, causing our product page to be empty.
Although the web version is working fine, the app is currently facing this problem.
We would greatly appreciate your guidance on resolving this issue.
Error code:
{"errors":[{"message":"Field 'products' doesn't exist on type 'Shop'","locations":[{"line":1,"column":7}],"path":["query","shop","products"],"extensions":{"code":"undefinedField","typeName":"Shop","fieldName":"products"}}]}
{"errors":[{"message":"Field 'collections' doesn't exist on type 'Shop'","locations":[{"line":1,"column":7}],"path":["query","shop","collections"],"extensions":{"code":"undefinedField","typeName":"Shop","fieldName":"collections"}},{"message":"Field 'articles' doesn't exist on type 'Shop'","locations":[{"line":1,"column":393}],"path":["query","shop","articles"],"extensions":{"code":"undefinedField","typeName":"Shop","fieldName":"articles"}}]}
Solved! Go to the solution
This is an accepted solution.
Hi Inbase_Vincent,
The error messages you're seeing indicate that the 'products', 'collections', and 'articles' fields do not exist on the 'Shop' type in the GraphQL schema you're using to query data.
Here are some things you can try to resolve the issue:
Check your GraphQL schema: Make sure the GraphQL schema you're using supports the 'products', 'collections', and 'articles' fields on the 'Shop' type. Not all versions of Shopify's API support all fields. You can check the documentation for your specific API version to see if these fields are supported.
Check your access scopes: Make sure your app has the necessary access scopes to retrieve product, collection, and article data. If your app does not have the required permissions, you will not be able to access these fields. You can check and update your app's access scopes in the Shopify admin.
Check your query syntax: Make sure your GraphQL queries are correctly formatted. It's possible that a typo or syntax error in your query is causing this issue.
Here is an example of how you should structure your query:
{
shop {
name
products(first: 10) {
edges {
node {
title
id
}
}
}
}
}
Try the above troubleshooting approaches and let us know if you're still seeing issues,
Liam | Developer Advocate @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
This is an accepted solution.
Hi Inbase_Vincent,
The error messages you're seeing indicate that the 'products', 'collections', and 'articles' fields do not exist on the 'Shop' type in the GraphQL schema you're using to query data.
Here are some things you can try to resolve the issue:
Check your GraphQL schema: Make sure the GraphQL schema you're using supports the 'products', 'collections', and 'articles' fields on the 'Shop' type. Not all versions of Shopify's API support all fields. You can check the documentation for your specific API version to see if these fields are supported.
Check your access scopes: Make sure your app has the necessary access scopes to retrieve product, collection, and article data. If your app does not have the required permissions, you will not be able to access these fields. You can check and update your app's access scopes in the Shopify admin.
Check your query syntax: Make sure your GraphQL queries are correctly formatted. It's possible that a typo or syntax error in your query is causing this issue.
Here is an example of how you should structure your query:
{
shop {
name
products(first: 10) {
edges {
node {
title
id
}
}
}
}
}
Try the above troubleshooting approaches and let us know if you're still seeing issues,
Liam | Developer Advocate @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
Hi Liam,
Thanks for your reply.
We will follow your comments to re-try and see if it works.
Hi Liam, I'm developing an app using the Shopify Buy SDK. I'm encountering the same issue, so I ran your query in Postman, but it also gave me an error. Here it is:
SDK error:
here is the error:
{"errors":[{"message":"Field 'products' doesn't exist on type 'Shop'","locations":[{"line":1,"column":7}],"path":["query","shop","products"],"extensions":{"code":"undefinedField","typeName":"Shop","fieldName":"products"}}]}
Postman error:
I receive a product list once I take products out of the shop. Here is the query:
but the problem is SDK designed as I can only access products from the shop
val query = Storefront.query { rootQuery ->
rootQuery.shop { shopQuery ->
shopQuery.products({ args ->
args.first(10)
cursor?.let { args.after(it) }
}) { productConnectionQuery ->
productConnectionQuery.edges { productEdgeQuery ->
productEdgeQuery.node { productQuery ->
productQuery
.title()
.description()
.images({ args -> args.first(1) }) { imageConnectionQuery ->
imageConnectionQuery.edges { imageEdgeQuery ->
imageEdgeQuery.node { imageQuery ->
imageQuery.originalSrc()
}
}
}
}
}
productConnectionQuery.pageInfo { pageInfoQuery ->
pageInfoQuery.hasNextPage()
}
}
}
}