How to fix graphql parse error on $ using rails shopify_app gem?

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)

Hey @bmc121177 ,

I did some testing with this query using an API Client and received the same type of error, so I would not expect the issues to be with the the application specifically, and instead the formatting.

The example above appears to have a an extra set of { } curly brackets before and after the query. Based on what was shared, and using our Shopify GraphiQL Explorer - I was able to successfully format and complete the following request with no error (input variables used returned from the explorer):

query GetProductMetafields($ids: [ID!]!) {
  nodes(ids: $ids) {
    ... on Product {
      id
      title
      metafields(first: 5) {
        edges {
          node {
            namespace
            key
            value
          }
        }
      }
    }
  }
}

Input:
{
  "ids": [
    "gid://shopify/Product/1974208364566",
    "gid://shopify/Product/1974208397334"
  ]
}

My suggestions would be to take a closer look at how this app is building or formatting the request body, ideally using the raw request output as a starting point!

Hope this helps - Cheers!