Smart custom endpoint structure #2139
-
In our graphql app we need users to be able to download some files, this service had to be built outside of yoga. I don´t have any good suggestions how this could be accomplished, but it would have been really nice! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi @TorbjornHoltmon ! plugins: [
{
onRequest({ request, url, fetchAPI, endResponse }) {
if (url.pathname === '/my-endpoint') {
// do something
endResponse(
new fetchAPI.Response(...),
)
}
}
}
] The code above hooks into the HTTP request pipeline of Yoga. Then you can handle incoming requests differently as you wish. |
Beta Was this translation helpful? Give feedback.
Hi @TorbjornHoltmon !
We have Yoga's HTTP hooks in the plugin system that might help you in this case;
The code above hooks into the HTTP request pipeline of Yoga. Then you can handle incoming requests differently as you wish.
Also remember this uses Fetch API
https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API