I’m using the shopify_app gem and trying to get multiple products using the graphql Admin API. I can hardcode product Id’s and get a valid response. However, when using dynamic variables I get the error below in my terminal:
GraphQL::ParseError (Parse error on "$" (VAR_SIGN) at [2, 27]):
get_order_products = ShopifyAPI::GraphQL.client.parse <<-'GRAPHQL'
{
query getProducts($ids: [ID!]!) {
nodes(ids: $ids) {
... on Product {
id
title
metafields(first: 5) {
edges {
node {
namespace
key
value
}
}
}
}
}
}
}
GRAPHQL
{
"ids": ["gid://shopify/Product/abc123", "gid://shopify/Product/abc456"]
}
@result = ShopifyAPI::GraphQL.client.query(get_order_products)
I’m new to graphql but would have expected this to work based on [this shopify community forum post][1]](https://community.shopify.com/c/shopify-apis-and-sdks/query-array-of-product-ids-with-graphql-api-in-one-request/td-p/453152)