The GraphQL API is served over HTTP via a single endpoint (https://gql.waveapps.com/graphql/public) which expresses the full set of capabilities of Wave. This is in contrast to REST APIs which expose a suite of URLs each of which expose a single resource.
There are multiple GraphQL clients available to simplify the process of sending requests, but any tool that can send a HTTP request will suffice.
There are two common types of operations in GraphQL, a query
to request some data, and a mutation
to submit or change data.
To send a request, POST
a JSON-encoded body containing the GraphQL operation along with a Bearer
token in the Authorization
header (see Authentication). A valid request must contain query
key regardless of the operation, and may include variables
key (see Variables).
- Operation
-
query { user { id defaultEmail } }
- Response
-
{ "data": { "user": { "id": "VXNlcjo4NzRlNDA3NS1mNzhhLTRkNzktODhlMy01MmM1MWE5YjE4ZGI=", "defaultEmail": "jsmith@example.com" } } }
Example: Terminal using cURL
curl -X POST "https://gql.waveapps.com/graphql/public" \
-H "Authorization: Bearer <ACCESS_TOKEN>" \
-H "Content-Type: application/json" \
-d '{ "query": "query { user { id defaultEmail } }", "variables": {} }'
Example: JavaScript using fetch
fetch('https://gql.waveapps.com/graphql/public', {
method: 'POST',
headers: {
'Authorization': 'Bearer <ACCESS_TOKEN>',
'Content-Type': 'application/json',
},
body: JSON.stringify({
query: 'query { user { id defaultEmail } }',
variables: {}
})
})
.then(r => r.json())
.then(data => console.log(data));