getBlogByHandle method

Future<Blog> getBlogByHandle(
  1. String handle, {
  2. SortKeyArticle sortKeyArticle = SortKeyArticle.RELEVANCE,
  3. bool reverse = false,
})

Returns a Blog.

Returns the Blog that is associated to the handle. sortKeyArticle is meant for the List of Article in the Blog.

Implementation

Future<Blog> getBlogByHandle(String handle,
    {SortKeyArticle sortKeyArticle = SortKeyArticle.RELEVANCE,
    bool reverse = false}) async {
  final QueryOptions _options = WatchQueryOptions(
    document: gql(getBlogByHandleQuery),
    variables: {
      'handle': handle,
      'sortKey': sortKeyArticle.parseToString(),
      'reverseArticles': reverse
    },
    fetchPolicy: ShopifyConfig.fetchPolicy,
  );
  final QueryResult result = await _graphQLClient!.query(_options);
  checkForError(result);
  var response = result.data!['blogByHandle'];
  var newResponse = {'node': response};
  return Blog.fromGraphJson(newResponse);
}