getAllBlogs method

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

Returns a List of Blog.

Returns All Blog of the Shop.

Implementation

Future<List<Blog>?> getAllBlogs(
    {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(),
    },
    fetchPolicy: ShopifyConfig.fetchPolicy,
  );
  final QueryResult result = await _graphQLClient!.query(_options);
  checkForError(result);
  return (Blogs.fromGraphJson((result.data ?? const {})["blogs"] ?? const {}))
      .blogList;
}