Hey team if you get a list of ids from algolia and...
# prisma-whats-new
a
Hey team if you get a list of ids from algolia and you need extra info should you do an individual query using filter on each id or is there an easy way to query all of them through one call?
n
@aaronkchsu you can use the
allX
query with the filter parameter
id_in:[]
❤️ 1
a
❤️
Hey @nilan is it possible to default to grabbing all if there are no ids found with the same query?:D
thanks again for all the help!
n
hm, can you elaborate?
a
query AllBites { allBites(filter: { id_in: [""] }) { id title tags backgroundColor backgroundImage { url } sound { url } } }
so like return all the ids when the array you pass in is empty
😄
query AllBites($IDS: [String]) { allBites(filter: { id_in: $IDS }) { id title tags backgroundColor backgroundImage { url } sound { url } } }
also having trouble getting this query to work 😄 what needs to match in order for me to pass the array in ?:D
n
You could combine `@skip`/`@include`, or just handle the different queries in your app logic
so if you don't have a list of ids, you just use
allBites
without any filter at all
a
got it! that is awesome
👍 1
n
If you're interested in the directives, here's more information: https://www.graph.cool/docs/faq/how-to-use-graphql-directives-moach1gich/
but in your case it's probably simpler to handle it on the app logic layer 🙂
a
Thank you!:) also idk its more of an ios specific question so idk if thats in your forte but I am trying to setup the query to pass in the array
query AllBites($IDS: [String]) { allBites(filter: { id_in: $IDS }) { id title tags backgroundColor backgroundImage { url } sound { url } } }
i notice the documentation lets you pass in a string https://www.learnapollo.com/tutorial-ios/ios-03
is that the right syntax?
n
I don't know the syntax for arrays in iOS, but it's probably something like this:
Copy code
public final class BitesQuery: GraphQLQuery {

  ...

  public let ids: [String]

  public init(ids: [String]) {
    self.ids = ids
  }

  public var variables: GraphQLMap? {
    return ["ids": ids]
  }

  ...
}
a
Thank you so much!!
n
did that work? 😁