I need to make a request from my node server, to a graphQL API. The graphQL API I am using takes the query as the URL's query params, not in the body of the request. It also does not accept POST requests. I am having an issue stringifying something like
const query = {
student(id: studentId) {
personal {
address
grade
etc {morestuff}
}
}
}
how do I stringify this to send it as queryParams? I have tried the querystring module querystring(query) but it returns something like student= and that's it. I have tried JSON.stringify and was also unsuccessful. I need the above, to look like:
query=%7B%0A%20%20%20%20student(id%3A%20studentId)%20%7B%0A%20%20%20%20%20%20personal%20%7B%0A%20%20%20%20%20%20%20%20address%0A%20%20%20%20%20%20%20%20grade%0A%20%20%20%20%20%20%20%20etc%20%7Bmorestuff%7D%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%20%20%7D
(I used an online encoder/decoder for that!)
I know that there are GraphQL client libs out there but I am unsure if they are to be used server-to-server, I see them used from browser/clients. If I should be using a client lib, can you recommend one (a lightweight preferably) that supports GET requests (the last one I tried did not - it was called Prisma)
Any help is appreciated :)