Query that filters out NULL datetime fields

Hello,

for my Settings type:

type Settings @exclude(operations: [UPDATE, DELETE]){
    id: ID @id(autogenerate: true)
    fromDate: DateTime! @timestamp @readonly
    toDate: DateTime @readonly
    client: Client! @relationship(type: "HAS_SETTINGS", direction: IN)
}

I would like to get the current client setting (the one with toDate = NULL.

This does not work:

query Settings($settingsWhere: SettingsWhere, $settingsOptions: SettingsOptions) {
  settings (where: {client:{login:"developers+adhoc@acme.com"}, toDate:NULL}){
    fromDate
    toDate
    client {
      login
    }
  }
}

Got the error in graphql client: DateTime cannot represent non string value

I also tried with different combinations of Logical operators (AND, OR, NOT) on the null field, but no luck.

Any idea?
Thanks,
Milan

Hi Milan,

It should work if you use null (lowercase) instead of NULL (uppercase), as null is case-sensitive.

Best regards,

Michael

HI Michael,
thanks for the reply.
It does not break with toDate:null but it also does not work -> returns empty result.

Hi Milan,

To double-check the basics, are you sure there is data in the database that matches your query?

Best regards,

Michael

Back to basics :) Thanks for the help!
null instead of NULL was the key

1 Like