curl -X POST -H 'Content-Type: application/json' -d '{"query":"{ user { id } }"}' http://localhost:4000/graphql

Category: Web App Development

curl -X POST -H 'Content-Type: application/json' -d '{"query":"{ user { id } }"}' http://localhost:4000/graphql

Query a GraphQL API with curl

Posts a GraphQL query document as JSON to the /graphql endpoint. GraphQL is a query language where clients request exactly the fields they need, and the query string here asks for the id of user. Many servers respond on POST with a JSON body, so pipe it into jq.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.