Inability to do simple GraphQL query filtering on node / edges like other GraphQl BaaS'es offer?

Yes there is a way, but maybe not a way that is easy to do right now. There are two approaches.

  1. Use DQL and var blocks
  • pros: the syntax is not that far different from GraphQL and the possibilities are limitless
  • cons: It ignores any and all @auth rules from the GraphQL schema and it does not map nicely to GraphQL API unless you write up a bunch of custom DQL queries for everywhere you want this at.
  1. Use multiple GraphQL queries in separate requests
  • pros: honors @auth rules, no additional custom DQL queries to write
  • cons: application layer has to be a tad bit smarter and at least two requests are needed for a somewhat simple query

^ Both of these I have detailed in other posts but don’t have the time at the moment to go dig them up.

Bonus, I guess there is also a third way that involves cascade but it might put a hurtin’ on your instance for performance depending on your query, structure and amount of data. Cascade is a post-query pre-response action so it still queries all but limits the response. Here is a quick mockup of that with your query above:

{
  queryObject(filter: { name: { eq: "Some search term string" } }) @cascade(fields: ["anotherObject"]) {
    id
    name
    anotherObject(filter: { id: ["0x123"] }) @cascade(fields: ["id"]) {
      id
      name
    }
  }
}
1 Like