wave-api 0.1.0

Typed Rust client for the Wave Accounting GraphQL API
Documentation
# Clients

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](https://graphql.org/code/#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](https://graphql.org/learn/queries/), 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](360018856751)). A valid request must contain `query` key regardless of the operation, and may include `variables` key (see [Variables](360024906591)).

Operation
:   ```graphql
    query {
      user {
        id
        defaultEmail
      }  
    }
    ```

Response
:   ```graphql
    {
      "data": {
        "user": {
          "id": "VXNlcjo4NzRlNDA3NS1mNzhhLTRkNzktODhlMy01MmM1MWE5YjE4ZGI=",
          "defaultEmail": "jsmith@example.com"
        }
      }
    }
    ```

### Example: Terminal using [cURL]https://curl.haxx.se/

```graphql
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]https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API

```graphql
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));
```