Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

variables are not working in a graphQL body #303

Closed
MyOrk64 opened this issue Jun 14, 2024 · 1 comment
Closed

variables are not working in a graphQL body #303

MyOrk64 opened this issue Jun 14, 2024 · 1 comment

Comments

@MyOrk64
Copy link

MyOrk64 commented Jun 14, 2024

Hi,
i am testing the shopify graphQL-API.
I can use variables in header, request, but not in everywhere in the body.
A simple query is runnung into errors because {{sku}} is not replaced its value.
Error message from Shopify: "Invalid global id 'gid://shopify/Product/{{sku}}'".
Suprisingliy it is, when i use it in the graphQL variable definition area.
I've tried "{{sku}}", \{\{sku\}\}, `$(sku))` , `"$(sku))"` ... and so on,

Why is it not working in the query definition,
but working with variable definitions message part of the body?

@sku=123456789
###
# @title ERROR with httpyac variable
POST https://{{storename}}.myshopify.com/admin/api/2024-04/graphql.json
...defaultHeaders

query getit {
  product( id: "gid://shopify/Product/{{sku}}" ) {
    id
    status
  }
}

###
# @titel replacement with graphQL variable is working
POST https://{{storename}}.myshopify.com/admin/api/2024-04/graphql.json
...defaultHeaders

query getit($sku: ID!) {
  product( id: $sku ) {
    id
    status
 }
}

{
"sku": "gid://shopify/Product/{{sku}}"
}
@AnWeber
Copy link
Owner

AnWeber commented Jun 15, 2024

@MyOrk64 Variables in variable definition part are rreplaced by requestVariableReplacer. Unfortunatly the gql query body is only added to the body after this replaced and this does prevent variable replacement. I added explicit replacing of variables for gql query body.
Fixed with next release

@AnWeber AnWeber closed this as completed Jun 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants