Reference doesn't work in the input query in Shopify Function

Reference doesn't work in the input query in Shopify Function

iandd0824
Shopify Partner
1 0 0

Hi All,

The regular query to have a referenced product from the metafield works in Shopify GraphQL App.
Reault query:

query cartTramsforms {
  cartTransforms(first: 10) {
    edges {
      node {
        id
        functionId
        metafields(first: 10) {
          edges {
            node {
              namespace
              key
              value
              reference {
                ... on Product {
                  id
                  title
                }
              }
            }
          }
        }
      }
    }
  }
}

Output:

{
  "data": {
    "cartTransforms": {
      "edges": [
        {
          "node": {
            "id": "gid://shopify/CartTransform/22118573",
            "functionId": "5757998b-132a-4c93-b076-857bb0d7ebfb",
            "metafields": {
              "edges": [
                {
                  "node": {
                    "namespace": "custom",
                    "key": "bundle_parent",
                    "value": "gid://shopify/Product/8029330997421",
                    "reference": {
                      "id": "gid://shopify/Product/8029330997421",
                      "title": "Meal Bundle"
                    }
                  }
                },
                {
                  "node": {
                    "namespace": "custom",
                    "key": "json_data",
                    "value": "{\"key\":\"value\"}",
                    "reference": null
                  }
                }
              ]
            }
          }
        }
      ]
    }
  },
  "extensions": {
    "cost": {
      "requestedQueryCost": 46,
      "actualQueryCost": 7,
      "throttleStatus": {
        "maximumAvailable": 2000,
        "currentlyAvailable": 1993,
        "restoreRate": 100
      }
    }
  }
}

When I put the same metafield reference in the input query of the Shopify Function Extension, it says [FAILED] Error 0: Cannot query field "reference" on type "Metafield".

 

 

Input Query:

query RunInput {
  cart {
    lines {
      id
      quantity
      ## Properties Values
      custom_data: attribute(key: "_custom_data") {
        value
      }
      merchandise {
        __typename
        ... on ProductVariant {
          product {
            id
            title
          }
        }
      }
    }
    seed_attribute: attribute(key: "_bundles") {
      value
    }
  }
  cartTransform {
    # Access the product referenced by the bundle_parent metafield
    bundle_parent: metafield(namespace: "custom", key: "bundle_parent") {
      value
      reference {
        ... on Product {
          id
          title
          handle
        }
      }
    }
  }
}

What should I do to get the referenced product information in the input query?


Appreciate any input, thanks. 

 

Replies 0 (0)