I want to query a nested field for multiple variab...
# orm-help
j
I want to query a nested field for multiple variables. In this case, I want to query RPR, but only return RPR if the label of the nested Region is given. One variable for the nested Region (field: label) works fine, but how can I filter on multiple variables of the same field? The way I see it, when I call up the query-client (in my case through Apollo), I want to give an array as a variable and let the query in the backend go through that array and query based on any of the variables given in the array. The resolver does nothing more then:
Copy code
rPRs: (root, args, ctx, info) => {
    return ctx.db.query.rPRs(args, info);
  },
My Schema:
Copy code
type RPR {
  id: ID! @Unique
  RPRID: String! @Unique
  state: String
  region: Region!
  resource: Resource!
  price: Float
  theme: String
  editionTitle: String
  information: String
}

type Region {
  id: ID! @Unique
  regionID: String! @Unique
  label: String! @Unique
  name: String! @Unique
  aov: Float!
  aov_multiplier: Float!
}
Query:
Copy code
query ADVICE_RESOURCES_QUERY($theme: String, $regio: String) {
  rPRs(where: {
    theme: $theme,
    region: {
      label: $regio
    }
  })
  {
    RPRID
    region {
      label
    }
  }
}
l
Something like this?
Copy code
where: { property_in: [$var1, $var2] }
j
Yeah, i can perform the query when I enter some static content variables in the query. for example:
Copy code
where: { OR: [ {region: { label: "var1" }}, {region: {label: "var2"}}]
But coming from the react-frontend, I would like to pass a array (with an unknown number of elements) to a GraphQL query and query { where: } on ANY of the elements in de passed array.
l
j
that example uses one variable to filter two different fields, I want to use an array of items to filter on one field
h
@Jeroen You can structure your application server's schema in such a way to accept an array as an input and pass it along to the client.