2023-03-25 00:33:08 +08:00
|
|
|
import { useSubscription, gql } from '@apollo/client';
|
|
|
|
import React, { useState } from "react";
|
|
|
|
|
|
|
|
export default function TotalOfUsers() {
|
2023-04-01 04:46:17 +08:00
|
|
|
const { loading, error, data } = useSubscription(
|
2023-03-25 00:33:08 +08:00
|
|
|
gql`subscription {
|
|
|
|
user_aggregate {
|
|
|
|
aggregate {
|
|
|
|
count
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}`
|
|
|
|
);
|
|
|
|
|
2023-04-01 04:46:17 +08:00
|
|
|
console.log('totalUsers', data);
|
2023-03-25 00:33:08 +08:00
|
|
|
|
2023-04-01 04:46:17 +08:00
|
|
|
return !loading && !error &&
|
|
|
|
(<div>Total of users: { data.user_aggregate.aggregate.count } </div>);
|
2023-03-25 00:33:08 +08:00
|
|
|
}
|