implemented identity, updated session, added 'workings' list
added paginated querying, added 'common'
This commit is contained in:
parent
027deba422
commit
6ada519e06
36 changed files with 1422 additions and 279 deletions
40
app/client/hooks/usePaginatedQuery.tsx
Normal file
40
app/client/hooks/usePaginatedQuery.tsx
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
import {
|
||||
ApolloError,
|
||||
ApolloQueryResult,
|
||||
MaybeMasked,
|
||||
OperationVariables,
|
||||
useQuery
|
||||
} from '@apollo/client';
|
||||
import { DocumentNode } from 'graphql';
|
||||
|
||||
interface UsePaginatedQueryProps {
|
||||
query: DocumentNode;
|
||||
input: {
|
||||
filter: {
|
||||
terms?: string | null;
|
||||
offset?: number | null;
|
||||
size?: number | null;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
interface UsePaginatedQueryReturn<T> {
|
||||
data?: MaybeMasked<T> | undefined;
|
||||
loading: boolean;
|
||||
error: ApolloError | undefined;
|
||||
refetch: (
|
||||
variables?: Partial<OperationVariables> | undefined
|
||||
) => Promise<ApolloQueryResult<MaybeMasked<T>>>;
|
||||
}
|
||||
|
||||
export function usePaginatedQuery<T>(props: UsePaginatedQueryProps): UsePaginatedQueryReturn<T> {
|
||||
const { data, loading, error, refetch } = useQuery<T>(props.query, {
|
||||
variables: { input: props.input }
|
||||
});
|
||||
return {
|
||||
data,
|
||||
loading,
|
||||
error,
|
||||
refetch
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue