question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

aws appsync combine filter operators

See original GitHub issue

Is it possible in AWS appsync / amplify to combine filter operators, like:

` const filterInput = {

    or:[

      {
      and: [
              {createdById: { eq: userID }},
              {chatWithId: { eq: chatWithUser.id }}
            ]
      },
      {
      and:  [
              {createdById: { eq: chatWithUser.id }},
              {chatWithId: { eq: userID }}
            ]
      }
    ]
  }

`

Because for me this is not filtering / working as expected.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

8reactions
olivier545commented, Apr 19, 2020

It works ! For those still trying, here is a working example :

query list { list (filter :{ and: [ { available: {eq: true}}, { id: {eq: “XXXXX”}}, { or: [ {promo: {eq: true}}, {price: {between : [40,45] }} ] } ]} ) { items { id price } } }

0reactions
jdanielsyeahcommented, Nov 8, 2022

When using the AppSync console, using the Query builder doesn’t generate a useable code: image

For example, clicking the ‘or’ option and then providing a value ‘myName’ for the ‘name’ field generates this:

query MyQuery {
  listInputSchemas(filter: {or: {name: {eq: "myName"}}}) {
    items {
      id
      name
    }
  }
}

It takes a bit of working out from here that you should wrap the {name: {eq: "myName"} section in square [] brackets. It would be useful if the [] were generated and with new lines/indentation to make it more obvious what the intention is.

Read more comments on GitHub >

github_iconTop Results From Across the Web

aws appsync combine filter operators - Stack Overflow
What I try to achieve is combine operator filters. So I want to filter on the firsts AND - OR - on the...
Read more >
Enhanced subscription filtering - AWS AppSync
Learn about enhanced subscription filtering in AWS AppSync. ... API subscription resolvers by using filters that support additional logical operators.
Read more >
API (GraphQL) - Fetch data - JavaScript - AWS Amplify Docs
Compound Filters. You can combine filters with and , or , and not boolean logic. Observe, in the autogenerated schema above, ...
Read more >
AppSync Insights Part 2: Implementing a reusable and generic ...
In our solution a query with a filter looks like this: ... we again combine them with the AND operator: in the example...
Read more >
Filters, IN comparison operator, toDynamoDBFilterExpression()
That function transforms the filter input according to the documentation (https://docs.aws.amazon.com/appsync/latest/devguide/resolver-util-reference.html).
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found