author BounceCode, Inc.
 *  packageDocumentation import { useApolloClient , QueryOptions , OperationVariables , } from '@apollo/client' ; import { useCallback } from 'react' ; import { UsersDocument , UsersQuery } from 'client/generated/graphql' ; import { QueryResult , Query } from 'material-table' ; export interface ITableDataCallback { ( query ) : Promise < QueryResult < any > > ; } const useUserTableDataCallback = ( options = { } ) => { const client = useApolloClient ( ) ; return useCallback < ITableDataCallback > ( async ( query ) => { const { data } = await client . query < UsersQuery > ( { ... options , query : UsersDocument , variables : { ... options . variables , take : query . pageSize , skip : query . page * query . pageSize , } , } ) ; console . log ( data ?. users ) ; return { data : data ?. users . map ( user => ( { ... user } ) ) || [ ] , page : query . page , totalCount : 100 , } ; } , [ ] ) ; } ; export default useUserTableDataCallback ;