0

Im trying to query a collection and filter it depends on the $path var but it either returns empty or throwing an error

<page-query>
query Gallery($path: String!){
  photos : allPhotos(filter: { nameFromGalleries: { contains: [$path]}}){
    edges{
      node{
        nameFromGalleries
        galleries
        attachments{
          thumbnails{
            full{
              url
            }
          }
        }
      }
    }
  }
</page-query>

for another query on the same page it works just fine

  gallery : gallery(path: $path){
    title
    children{
      name
      path
    }
  }
nadiTime
  • 151
  • 1
  • 9
  • In the first query you're passing in the variables/parameters wrong. The variables should be in form of an object if they're nested. Something like `allPhotos(filter : { nameFromGalleries : $path })...` then you'll access `filter.nameFromGalleries` in the backend to get the value of $path – kimobrian254 May 21 '20 at 11:26
  • Thanks @kimobrian254, I edited question, still filter doesnt work :( how does the variables work here? – nadiTime May 21 '20 at 11:38
  • what's the exact error? I might be able to help with some context. – kimobrian254 May 21 '20 at 11:43
  • Variables are just like named function parameters like `queryName(var1: value, var2: value, var3: { varA: value, varB: value}, var4: [values])`. This demos either single variables, objects as variables or array as variables. – kimobrian254 May 21 '20 at 11:50

0 Answers0