June 2025
Intermediate to advanced
837 pages
24h 50m
English
GraphQL is a query language that uses HTTP as a transport layer, so it’s on the same level as REST, for example. This means you can address a GraphQL interface like the one you just implemented using a very ordinary HTTP client. For example, you can query your new interface from the command line using the code shown in Listing 11.4.
$ curl -X POST -H "Content-Type: application/json" --data '{"query": "{ greet }"}' http://localhost:8080/graphql {"data":{"greet":"Hello GraphQL"}} Listing 11.4 Querying the GraphQL Interface with cURL
The query is an HTTP POST request with the content type header application/json. As the message body, you send the data, in this case, a JavaScript Object Notation (JSON) structure with the ...
Read now
Unlock full access