Difference Between Amplify.DataStore.query and Amplify.API.query with QueryPredicate?

47 Views Asked by At

Why does the first method, which uses Amplify.DataStore.query, return 0 items from the table, while the second method, which uses Amplify.API.query with a queryPredicate, returns all the items in the table?

method 1:

final products = await Amplify.DataStore.query<Product>(Product.classType);

method 2:

  final queryPredicate = type != null ? Product.TYPE.eq(type) : null;
      final request = ModelQueries.list(Product.classType, where: queryPredicate);
      final response = await Amplify.API.query(request: request,).response;
      final products = response.data?.items;

Why does the first method, which uses Amplify.DataStore.query, return 0 items from the table, while the second method, which uses Amplify.API.query with a queryPredicate, returns all the items in the table?

0

There are 0 best solutions below