0

Hello everyone I am having some issues with the way I used to query my data before updating to Hasura 2.0 (I am currently on Beta 1), so Before 2.0 if you sent a null value to a query it would act as a wildcard * , now that I updated to 2.0 all query variables must have non-null values, is there anyway I could get around this?

A small query will serve as an example:

query get_student_organization($authorId: Int, $gradeId: Int, $groupId: Int, $schoolId: Int) {
  validation: student_organization(where: {author_id: {_eq: $authorId}, escuela_id: {_eq: $schoolId}, grado_id: {_eq: $gradeId}, grupo_id: {_eq: $groupId}}) {
    id
  }
}

so if I send it with only

{"authorId": 5455}

I expect all other variables to act as wildcards. Any help is welcome :)

1 Answers1

0

you can simply send your whole where object from your front-end! That way you can simply omit the null variables at all. For this, you need to tweak your query a little bit.

query get_student_organization($wh_frontend: student_organization_bool_exp!) {
  validation: student_organization(where: $wh_frontedn) {
    id
  }
}

In the variables section, add your non-null variables only:

{
  "where_fe": {
    "authorId": 5455
  }
}

so this time your haven't sent the schoolId, groupId and gradeId which serves your need for a wild-card.

Dharman
  • 30,962
  • 25
  • 85
  • 135