I am using `` query:
const GET_COMMENTS = gql`
query getComments {
getComments (where: {code: "/about-us" }) {
id
text
createdAt
}
}
`
....
const { loading, error, data } = useQuery(GET_COMMENTS);
in my code...
The code is fetching comments from the server in comment object is a date: string! property, I would like to transform this date: string! into javascript date (new Date(comment.date)) how can I do it directly after data fetch?
I don't want to transform every render is called.
Is there any something like this?:
const { loading, error, data } =
useQuery(
GET_COMMENTS,
{
transform: (data) => data.map(comment => ({...comment , date: new Date(comment.date)}) )
}
);
Thank you for your help!