I am using graphql-codegen with react-query to generate mutations like these.
const [createLogMutation, {}] = useCreateLogMutation({
variables: {
data: {
logType,
message,
task
}
}
})
I want to create a helper function which handles the logging to database using this function. However, I am not able to use hook inside a plain function. What could be a good way to implement the helper function?
I want a simpler method like platformlogger.log(type, message, task) which would do the job. Without a helper function, I would have to call the above mutation everywhere I want to implement the logger.