How to make a request to a hosted GraphQL API with a local external (java) program?

Viewed 8

I have to create a program (in Java) which will send a GraphQL request to an API accessible at the address https://www.[web.site.name].fr/api/v2/graphql (with Playground available l address https://www.[web.site.name].fr/graphql, but it doesn't really matter, it's only for testing.). Once my request has been made, I must also receive the response in JSON in my program/console/variable or other, I must receive it locally in any case.

The website provides a short documentation giving the only useful info that you can do tests on a terminal with Curl :

curl 'https://www.[web.site.name].fr/api/v2/graphql' \
    --header 'Authorization: Bearer [here my personal TOKEN]' \
    --header 'Content-Type: application/json' \
    --data '{ "query": "[query request here]", "variables": { [variable I might need] } }'

This Curl request returns a response in JSON format as we could have in Playground, GraphiQL...

I spent the day documenting myself and impossible to find how to make the connection between a Java project (still empty) and this external API already hosted... I only find how to CREATE an API locally or how to make requests on a API but local (except that mine is not local but hosted on the web as said before)

With all the documentation I've seen today, I've heard about "endpoint", "http service", "http client", I don't know if that's what I should focus on. I also heard of "graphql-java" but I couldn't use it (or even initialize it, the doc isn't very clear to me...)

Do you have a solution, an idea, a proposal?

0 Answers
Related