...
##### a. Obtain API Endpoint:
\*\*All API requests, whether queries or mutations, are sent to a single HTTP endpoint.
...
If you reference variables in your GraphQL document, the value for variables MUST be a JSON object containing the key/value pairs for each variable as can be seen below.
JSON
Code Block | ||
---|---|---|
| ||
{ "query": "a GraphQL document goes here that references $var1, $var2, and $var3", "variables": { "var1": 10, "var2": { "some": "data", "for": "var2" }, "var3": ["a","list","of","values"] } } |
To send that to our API, it has to be wrapped in a JSON object with a query key:
Text
Code Block | ||
---|---|---|
| ||
{ "query": "query { hello }" } |
...
Below is how you can make a request using cURL:
cURL
Code Block | ||
---|---|---|
| ||
curl -H 'Content-Type: application/json' -X POST https://staging-ignite.originate.ng/graphql -d '{"query": "query { hello }"}' |
...