getAllBlogs method

Future<List<Blog>?> getAllBlogs({
  1. bool deleteThisPartOfCache = false,
  2. SortKeyBlog sortKeyBlog = SortKeyBlog.HANDLE,
  3. bool reverseBlogs = false,
  4. bool reverseArticles = false,
})

Returns a List of Blog.

Returns All Blog of the Shop.

Implementation

Future<List<Blog>?> getAllBlogs(
    {bool deleteThisPartOfCache = false,
    SortKeyBlog sortKeyBlog = SortKeyBlog.HANDLE,
    bool reverseBlogs = false,
    bool reverseArticles = false}) async {
  final WatchQueryOptions _options =
      WatchQueryOptions(document: gql(getAllBlogsQuery), variables: {
    'reverseBlogs': reverseBlogs,
    'reverseArticles': reverseArticles,
    'sortKey': sortKeyBlog.parseToString(),
  });
  final QueryResult result = await _graphQLClient!.query(_options);
  checkForError(result);
  if (deleteThisPartOfCache) {
    _graphQLClient!.cache.writeQuery(_options.asRequest, data: {});
  }
  return (Blogs.fromGraphJson((result.data ?? const {})["blogs"] ?? const {}))
      .blogList;
}