0
votes

I am a traditional programmer new to GraphQL and I can't seem to find documentation on what I consider the basics, aka manipulating variables. Note: I am using GraphQL with Shopify(Admin API), through an app GraphiQL, so that my effect syntax and capabilities.

Here is a piece of hypo (& broken) code where I have two iterations of the same code block

  1. <>that tries to add two variables
  2. <>on that sum items in a list. The specific code in this lines are guesswork..

If anyone has suggestions on sources for example code or API docs beyond GraphQL site, I have been searching and nothing I have found addresses this type of functionality.

query fiveorTenOrders($n: Int = 5,$m: list =[5,5], $boo: Boolean = true) {
  FiveOrds: orders(first: $n) {
    edges @include(if: $boo) {
      node {
        ...ordrecs
      }
    }
  }
  #<<<HERE and as basic arithmetic>>> 
  TenOrds: orders(first: ($n+$n) {
    edges @skip(if: $boo) {
      node {
        ...ordrecs
        
  #<<<OR HERE ...as a sum of list>>> 
  TenOrds: orders(first: $m:SUM {
    edges @skip(if: $boo) {
      node {
        ...ordrecs      
      }
    }
  }
}

fragment ordrecs on Order {
  id
  name
  createdAt
  shippingAddress {
    id
    city
    provinceCode
    zip
  }
}
1

1 Answers

0
votes

GraphQL does not currently support this sort of functionality (and may never). Variables are used as-is with no way to apply arbitrary transformations to them. In your example, you would need to sum the values yourself on the client and then inject them into the query as a separate variable.