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.

Filter between using Connect component not returning all data

See original GitHub issue

I have the following schema in my project:

type Report @model {
  id: ID!
  alarmTime: AWSDateTime!
  ...
}

When I execute the following query in AWS AppSync console, I get the expected results.

query listReports {
  listReports(filter: {alarmTime: {between: ["2019-07-22T23:00:00Z","2019-07-23T22:59:59Z"]}}, limit: 100) {
    items {
      id
      alarmTime
      ...
    }
  }
}

The results in AWS AppSync queries console:

{
  "data": {
    "listReports": {
      "items": [
        {
          "id": "17a8158e-e0d4-4f48-aca9-526eea0e8c6b",
          "alarmTime": "2019-07-23T04:24:50.624Z"
          ...
        },
        {
          "id": "48964d94-2165-4b22-b141-ea1de5d489f7",
          "alarmTime": "2019-07-23T01:05:32.308Z"
          ...
        },
        {
          "id": "be328d11-9e64-4040-bfcc-3f71ce1c4003",
          "alarmTime": "2019-07-23T04:24:50.624Z"
          ...
        },
        {
          "id": "0f35f969-2abc-4fb8-8ef9-e33cfce5a453",
          "alarmTime": "2019-07-23T01:05:32.308Z"
          ...
        },
        {
          "id": "0380aa3b-6139-4bb8-a1c9-bad603f9c613",
          "alarmTime": "2019-07-23T01:05:32.308Z"
          ...
        },
        {
          "id": "6ff33fa4-5ee8-406d-9391-ff0acb1e483b",
          "alarmTime": "2019-07-23T01:05:32.308Z"
          ...
        }
      ]
    }
  }
}

But when I execute the same query using the Connect component in my project, It returns less data than expected.

<Connect
              query={graphqlOperation(queries.listReports,
                { filter: { alarmTime: { between: this.handleDateInput(this.state.selectedDate) } } }, { limit: 100 })}>
              {({ data: { listReports }, loading, error }) => {
                if (error) return (<h3>Error</h3>);
                if (loading || !listTodos) return (<h3>Loading...</h3>);
                console.log(listReports.items);
                return <ReportView reports={listReports.items} />;
              }}
            </Connect>

The results using Connect component:

(2) [{…}, {…}]
0: {id: "48964d94-2165-4b22-b141-ea1de5d489f7", alarmTime: "2019-07-23T01:05:32.308Z", …}
1: {id: "17a8158e-e0d4-4f48-aca9-526eea0e8c6b", alarmTime: "2019-07-23T04:24:50.624Z", …}
length: 2
__proto__: Array(0)

Dependencies:

  • “aws-amplify”: “^1.1.32”,
  • “aws-amplify-react”: “^2.3.11”,
  • “react”: “^16.8.6”,

Am I missing something?

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
watanabethaiscommented, Jul 25, 2019

The problem was actually this! I’ve corrected my query and the result comes as expected. Omg! I didn’t notice the braces in limit was the problem… sorry for that.

Thank you so much for your help @haverchuck !

0reactions
github-actions[bot]commented, Jun 12, 2021

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 or Discussions for those types of questions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Filtering data in a reducer then attaching it to a component ...
Returning an empty array you are sure that you are receiving the same type on your component. Your filter is fine. Only this...
Read more >
Connect: Extracting Data with mapStateToProps - React Redux
The first argument to a mapStateToProps function is the entire Redux store state (the same value returned by a call to store.getState() )....
Read more >
How to Use React Context to Share Data between Components
The first one, which you may already know about if you are a React developer, is to use props to pass data down...
Read more >
How to Search and Filter Components in React - freeCodeCamp
Basically we will fetch the data from our API endpoint https://restcountries.eu/rest/v2/all and display the data in a user readable form.
Read more >
How to search/filter through data in React - Level Up Coding
We will using the hook “useState” to hold our data returned from ... The next step is to create 2 pieces of state...
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