Technically we are just getting data from the server, so it must be a GET request.
Well that's only the case when you run a query
, not when you run a mutation
.
But more importantly, you're not just getting data from the server, you're also sending data to the server: the query document and optionally some variables and an operation name. Since GET
requests ought not to have a body, POST
was chosen.
That said, this is just a convention adopted by most endpoints, the GraphQL spec does not actually require it but allows any transport. You could also send the query document in a header, you could send it as part of the URL, you could send only the name of a predefined query to the server, then you could easily use GET
requests - but beware of size limits and impact of caching.