How Do I retrieve / update Function Metafields through GraphQL queries

How Do I retrieve / update Function Metafields through GraphQL queries

fwallace
Shopify Partner
40 0 4

I am trying to add user configuration to a Shopify Discount Function. The Remix / React example does not work, when you try and add the components, error city:

 

remix_errors1.png

 

Ok, use the legacy deps flag:

 

remix_legacy_peer_deps.png

 

Which hosed the app completely when trying to shopify app deploy (or dev):

 

cannot_find_javy.png

 

Isn't there a simpler way to do this, by just using an app to retrieve the existing metafields of a function, and then update them? I can do that in Rails, Sinatra, easy if I had the queries and avoid the React stuff. Just one user will be using the configuration at a time so I am not worried about performance.

 

This query just gives a "bad request" response but in Graphql it works:

 

curl -X POST \
https://mystore.myshopify.com/admin/api/2024-04/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: from_shopify-env-file' \
-d '{
"query": ""query DiscountAutomaticNodeMetafields($ownerId: ID!) {
                    discountNode(id: $ownerId) {
                      metafields(first: 7) {
                        edges {
                          node {
                            namespace
                            key
                            value
                          }
                        }
                      }
                    }
                  }
                  {
                    "ownerId": "gid://shopify/DiscountAutomaticNode/123456"
                  }"
}'

Is there any way to query and update the metafields of a function OUTSIDE Graphql, that is what I am asking and I can forget about React and what node library is nuking javy for now.

 

[I have another copy of this shopify function in Github but without the Remix template. Function worked until I tried adding the React components and had to use the "--legacy-peer-deps" flag.

 

Just trying to get this into production.

 

Thanks.

Replies 0 (0)