Filter on null or "Not exists" for graphql fields
See original GitHub issueIs your feature request related to a problem? Please describe.
I can’t filter on whether or not a field is null or “not exists”
Describe the solution you’d like
There are a couple ways of solving this, but the easiest solution I can think of is to allow this:
const filter: ModelFooFilterInput = {
field: { eq: null }
};
const results: ListFoosQuery = await this.apiService.ListStudyFoos(filter);
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
Graphql query only not null objects - Stack Overflow
If you don't want certain data in your response, you have to filter it somewhere on the server. The only thing you have...
Read more >Using nullability in GraphQL
A field can either be nullable or non-null, and this tells you whether or not you could receive a null value when you...
Read more >Nulls in GraphQL: Cheatsheet - Hasura
Nulls in the query. A GraphQL query can have fields and inputs, with or without variables. Fields are always optional, whether nullable or...
Read more >Search and Filtering - GraphQL - Dgraph
You can filter queries to find objects with a non-null value in a specified field using the has keyword. The has keyword can...
Read more >When To Use GraphQL Non-Null Fields | by Caleb Meredith
In the GraphQL type system all types are nullable by default. This means that a type like Int can take any integer (...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@malcomm I believe the filter you might be looking for in this scenario is if the attribute does not exist on the given record. Given this schema
If I wanted to filter by Restaurants that did not have a description then I would filter as follows:
If can also or them in the filter so it returns the field being null or the attribute not existing
This issue has been automatically locked since there hasn’t been any recent activity after it was closed. Please open a new issue for related bugs.
Looking for a help forum? We recommend joining the Amplify Community Discord server
*-help
channels for those types of questions.