feature: order people results
This commit is contained in:
@ -17,8 +17,8 @@ const StyledPeopleContainer = styled.div`
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
export const GET_PEOPLE = gql`
|
export const GET_PEOPLE = gql`
|
||||||
query GetPeople {
|
query GetPeople($orderBy: [person_order_by!]) {
|
||||||
person {
|
person(order_by: $orderBy) {
|
||||||
id
|
id
|
||||||
phone
|
phone
|
||||||
email
|
email
|
||||||
@ -34,8 +34,16 @@ export const GET_PEOPLE = gql`
|
|||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
const orderBy = [
|
||||||
|
{
|
||||||
|
created_at: 'desc',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
function People() {
|
function People() {
|
||||||
const { data } = useQuery<{ person: GraphqlPerson[] }>(GET_PEOPLE);
|
const { data } = useQuery<{ person: GraphqlPerson[] }>(GET_PEOPLE, {
|
||||||
|
variables: { orderBy },
|
||||||
|
});
|
||||||
|
|
||||||
const mydata: Person[] = data ? data.person.map(mapPerson) : defaultData;
|
const mydata: Person[] = data ? data.person.map(mapPerson) : defaultData;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user