getServerCartCount method
Implementation
Future getServerCartCount(String userId) async {
GraphQLClient _client = graphQLConfiguration.clientToQuery();
var cartCountGql = """
query getCartNoForUser(\$userId: String) {
getCartNoForUser(userId: \$userId) {
noOfProducts
__typename
}
}
""";
final vble = {
"userId": userId,
};
QueryResult result = await _client.query(QueryOptions(
document: gql(cartCountGql),
variables: vble,
fetchPolicy: FetchPolicy.networkOnly,
));
if (!result.hasException) {
var serverCartCountModel = result.data!["getCartNoForUser"];
if (serverCartCountModel != null) {
serverCartCount = cartCountFromJson(serverCartCountModel);
return serverCartCount;
}
}
return serverCartCount;
}