Skip to Content
All memories

AWS amplify filter data

 — #aws

In this article, we are going to discuss about the frontend react queries to fetch the data from database using amplify and graphql.

  • create graphql api to interact with database. Follow this official docs

Filter by equal data

const data = await API.graphql(
  graphqlOperation(
    queries.listTodos(
      (filter: {
        field: {
          eq: 'string',
        },
      }),
    ),
  ),
);

console.log(data);

Filter by or and equal data

const data = await API.graphql(
  graphqlOperation(
    queries.listTodos(
      (filter: {
        or: [
          {
            id: { eq: 1 },
          },
          {
            id: { eq: 2 },
          },
        ],
      }),
    ),
  ),
);

Keywords

  • aws amlpify frontend qurey to filter data
  • Filter data by specific value in aws amplify.