graphQL syntax Questions

  1. How to negate a query in graphQL?
    Answer:

  2. How to query a collection field for isNotEmpty? I only see isEmpty.
    Answer: callStats: {isEmpty: false}

  3. Is it possible to reference the record count of a container field in a query? E,g, filter for count>3
    Answer: No

  4. Is it possible to use logical operators like and, or, not in graphQL queries/filters? I.e. filter for a Text field that is either null or empty.
    Answer:

  5. Is it possible for a graphQL mutation to reset a Text field to null? I.e. the default field value, not the empty string
    Answer: Yes: update( fieldname: null )

What do you mean by negate a query? Do you mean perform a subsequent query that reverses the changes?

The ‘count’ is not a real field that can be read, so the answer is no AFAIK.
I believe the only thing you can do is to check if there are any linked entities (i.e. count > 0)

1 Like

To logically negate (part of) a filter condition – e.g.,

not: {
   less: {a, 10}      # these terms are implicitly "and"
   is:   {b, "20"}
}

More graphQL syntax questions:

The graphQL docs do not list any logical operators – "and, “or”, and “not” are all absent.

So how would I test whether a String field is either null or empty (“”)?

or: { field: {isNull: true}, field: {is: ""} }

Can a graphQL “find” query return only the count of records found, and no record contents?

Hello, @Matt_Blais

Please find my comments below

So how would I test whether a String field is either null or empty (“”)?

Indeed there is no or operation. We propose use several queries in this case.

{
  nullName: findProjects(name:{isNull:true}){
    id
  }
  emptyName: findProjects(name:{is:""}){
    id
  }
}

Can a graphQL “find” query return only the count of records found, and no record contents?

Unfortunately, it is not supported in GraphQL for now. However many things can be done using native Fibery API.

Thanks,
Oleg