Loop in a query

Bit of a long shot, I have this

query ($firstone: String!, $secondone: String!){
  firstone: urlRedirects(first: 10, query: $firstone) {
    edges {
      node {
        id
        path
        target
      }
    }
  }
  secondone: urlRedirects(first: 10, query: $secondone) {
    edges {
      node {
        id
        path
        target
      }
    }
  }
}

With

{"firstone": "target:/products/a-haunting-in-the-arctic-cj-cooke-9*",
"secondone": "target:/products/a-haunting-in-the-arctic-cj-cooke-9*"
}

That works fine, but I am probably going to have a lot of queries and would like to look through the input file

for do this many times
dynamicvalue: urlRedirects(first: 10, query: $dynamicvalue) {
edges {
node {
id
path
target
}
}
}

Does anyone know if that is possible?

Thanks

Grant

GQL doesn’t have a dynamic input capability like you’re mentioning. The solution would be to dynamically create the list of queries you have above in code (e.g. in a for loop)

Thanks. I did look at some alternatives, I was hoping that passing in a list would work [String!]! but that doesn’t look to be supported, I thin thought multiple requests in the same call, like below

query ($firstone: String!, $secondone: String!){
  firstone: urlRedirects(first: 10, query: $firstone) {
    edges {
      node {
        ...RedirectFields
      }
    }
  }
  secondone: urlRedirects(first: 10, query: $secondone) {
    edges {
      node {
        ...RedirectFields
      }
    }
  }
}

fragment RedirectFields on UrlRedirect {
    id
    path
    target
}

That looks to work, but is cumbersome. I ended up with ORs in the query, but worry on that one I could be limited by the number of ours

For context. I am want to get all the data for a product, collection, variants and the redirects associated to the product. I am starting by getting as much product data as I can. I do it in batches with some products first, then collections and then query redirects by target (base).
I use the bulk operation for this.