Skip to content

Commit

Permalink
docs: add pagination page (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
openoms committed Nov 3, 2023
1 parent 5a58b72 commit 21e3d9e
Show file tree
Hide file tree
Showing 11 changed files with 177 additions and 19 deletions.
4 changes: 2 additions & 2 deletions docs/api/btc-ln-receive.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,6 @@ query Me {
</AuthProvider>

:::tip
To test the GraphQL requests further use the GraphQL playground at [api.blink.sv/graphql](https://api.blink.sv/graphql) for mainnet or [api.staging.galoy.io/graphql](https://api.staging.galoy.io/graphql) for staging.
Can also use the [Galoy API Postman collection](https://documenter.getpostman.com/view/29391384/2s9YCAQq3z#ac3751d8-c116-408b-9129-d6e365da590b) to find examples in multiple programming languages.
To test the GraphQL requests further use the GraphQL playground at [api.blink.sv/graphql](https://api.blink.sv/graphql) for mainnet or [api.staging.galoy.io/graphql](https://api.staging.galoy.io/graphql) for staging.<br />
Check out the [Galoy API Postman collection](https://documenter.getpostman.com/view/29391384/2s9YCAQq3z#ac3751d8-c116-408b-9129-d6e365da590b) to find examples in multiple programming languages.
:::
4 changes: 2 additions & 2 deletions docs/api/btc-ln-send.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,6 @@ mutation LnInvoicePaymentSend($input: LnInvoicePaymentInput!) {
</AuthProvider>

:::tip
To test the GraphQL requests further use the GraphQL playground at [api.blink.sv/graphql](https://api.blink.sv/graphql) for mainnet or [api.staging.galoy.io/graphql](https://api.staging.galoy.io/graphql) for staging.
Can also use the [Galoy API Postman collection](https://documenter.getpostman.com/view/29391384/2s9YCAQq3z#ac3751d8-c116-408b-9129-d6e365da590b) to find examples in multiple programming languages.
To test the GraphQL requests further use the GraphQL playground at [api.blink.sv/graphql](https://api.blink.sv/graphql) for mainnet or [api.staging.galoy.io/graphql](https://api.staging.galoy.io/graphql) for staging.<br />
Check out the [Galoy API Postman collection](https://documenter.getpostman.com/view/29391384/2s9YCAQq3z#ac3751d8-c116-408b-9129-d6e365da590b) to find examples in multiple programming languages.
:::
4 changes: 2 additions & 2 deletions docs/api/btc-onchain-receive.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,6 @@ query Me {
</AuthProvider>

:::tip
To test the GraphQL requests further use the GraphQL playground at [api.blink.sv/graphql](https://api.blink.sv/graphql) for mainnet or [api.staging.galoy.io/graphql](https://api.staging.galoy.io/graphql) for staging.
Can also use the [Galoy API Postman collection](https://documenter.getpostman.com/view/29391384/2s9YCAQq3z#ac3751d8-c116-408b-9129-d6e365da590b) to find examples in multiple programming languages.
To test the GraphQL requests further use the GraphQL playground at [api.blink.sv/graphql](https://api.blink.sv/graphql) for mainnet or [api.staging.galoy.io/graphql](https://api.staging.galoy.io/graphql) for staging.<br />
Check out the [Galoy API Postman collection](https://documenter.getpostman.com/view/29391384/2s9YCAQq3z#ac3751d8-c116-408b-9129-d6e365da590b) to find examples in multiple programming languages.
:::
4 changes: 2 additions & 2 deletions docs/api/btc-onchain-send.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,6 @@ mutation onChainUsdPaymentSend($input: OnChainUsdPaymentSendInput!) {
</AuthProvider>

:::tip
To test the GraphQL requests further use the GraphQL playground at [api.blink.sv/graphql](https://api.blink.sv/graphql) for mainnet or [api.staging.galoy.io/graphql](https://api.staging.galoy.io/graphql) for staging.
Can also use the [Galoy API Postman collection](https://documenter.getpostman.com/view/29391384/2s9YCAQq3z#ac3751d8-c116-408b-9129-d6e365da590b) to find examples in multiple programming languages.
To test the GraphQL requests further use the GraphQL playground at [api.blink.sv/graphql](https://api.blink.sv/graphql) for mainnet or [api.staging.galoy.io/graphql](https://api.staging.galoy.io/graphql) for staging.<br />
Check out the [Galoy API Postman collection](https://documenter.getpostman.com/view/29391384/2s9YCAQq3z#ac3751d8-c116-408b-9129-d6e365da590b) to find examples in multiple programming languages.
:::
157 changes: 157 additions & 0 deletions docs/api/pagination.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
---
id: pagination
title: Pagination
slug: /api/pagination
---

When you access the list of transactions all items will have an associated cursor position. This cursor can be used to paginate through the list by defining the `after` and / or `before` variable in the GraphQL request.

## Example request with pagination

Note the `pageInfo` object containing the cursor and page values. The `edges` object contains the transaction data.

* `endCursor`: When paginating forwards, the cursor to continue.
* `hasNextPage`: When paginating forwards, are there more items?
* `hasPreviousPage`: When paginating backwards, are there more items?
* `startCursor`: When paginating backwards, the cursor to continue.

```graphql
query transactionsForAccount($walletIds: [WalletId], $first: Int, $after: String) {
me {
id
defaultAccount {
transactions(walletIds: $walletIds, first: $first, after: $after) {
pageInfo {
endCursor
hasNextPage
hasPreviousPage
startCursor
}
edges {
cursor
node {
direction
settlementCurrency
settlementDisplayAmount
status
}
}
}
}
}
}
```

## Variables

* `first`: Returns the first n items from the list.
* `after`: Returns the items in the list that come after the specified cursor.
* `last`: Returns the last n items from the list.
* `before`: Returns the items in the list that come before the specified cursor.

The variables used in the request to show the first 2 transactions for the default account:

```json
{
"first": 2,
"after": null
}
```

Sample response showing the first 2 transactions:
```json
{
"data": {
"me": {
"id": "dd3771d0-66b2-4b28-8757-b1a5db0f8fcf",
"defaultAccount": {
"transactions": {
"pageInfo": {
"endCursor": "6538b68c491e13fd6416722d",
"hasNextPage": true,
"hasPreviousPage": false,
"startCursor": "6538bda9491e13fd6416b5f3"
},
"edges": [
{
"cursor": "6538bda9491e13fd6416b5f3",
"node": {
"direction": "RECEIVE",
"settlementCurrency": "USD",
"settlementDisplayAmount": "0.01",
"status": "SUCCESS"
}
},
{
"cursor": "6538b68c491e13fd6416722d",
"node": {
"direction": "RECEIVE",
"settlementCurrency": "USD",
"settlementDisplayAmount": "1.00",
"status": "SUCCESS"
}
}
]
}
}
}
}
}
```

## Request to show the next two transactions

To show the next two transactions the `endCursor` value from the previous response is used as the `after` variable in the next request:

```json
{
"first": 2,
"after": "653787e933905fc03c13e2bc"
}
```

Response showing the next two transactions:
```json
{
"data": {
"me": {
"id": "dd3771d0-66b2-4b28-8757-b1a5db0f8fcf",
"defaultAccount": {
"transactions": {
"pageInfo": {
"endCursor": "653787c033905fc03c13e0a3",
"hasNextPage": true,
"hasPreviousPage": false,
"startCursor": "653787e933905fc03c13e286"
},
"edges": [
{
"cursor": "653787e933905fc03c13e286",
"node": {
"direction": "SEND",
"settlementCurrency": "BTC",
"settlementDisplayAmount": "-0.47",
"status": "SUCCESS"
}
},
{
"cursor": "653787c033905fc03c13e0a3",
"node": {
"direction": "SEND",
"settlementCurrency": "BTC",
"settlementDisplayAmount": "-0.47",
"status": "SUCCESS"
}
}
]
}
}
}
}
}
```

:::tip
To test the GraphQL requests further use the GraphQL playground at [api.blink.sv/graphql](https://api.blink.sv/graphql) for mainnet or [api.staging.galoy.io/graphql](https://api.staging.galoy.io/graphql) for staging.<br />
Check out the [Galoy API Postman collection](https://documenter.getpostman.com/view/29391384/2s9YCAQq3z#ae685bc1-d637-48b2-8e32-4600eefc9a4e) to find examples in multiple programming languages.
:::
4 changes: 2 additions & 2 deletions docs/api/usd-ln-receive.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,6 @@ query Me {
</AuthProvider>

:::tip
To test the GraphQL requests further use the GraphQL playground at [api.blink.sv/graphql](https://api.blink.sv/graphql) for mainnet or [api.staging.galoy.io/graphql](https://api.staging.galoy.io/graphql) for staging.
Can also use the [Galoy API Postman collection](https://documenter.getpostman.com/view/29391384/2s9YCAQq3z#ed78e464-9874-4bf7-9b7b-92e5a898db83) to find examples in multiple programming languages.
To test the GraphQL requests further use the GraphQL playground at [api.blink.sv/graphql](https://api.blink.sv/graphql) for mainnet or [api.staging.galoy.io/graphql](https://api.staging.galoy.io/graphql) for staging.<br />
Check out the [Galoy API Postman collection](https://documenter.getpostman.com/view/29391384/2s9YCAQq3z#ed78e464-9874-4bf7-9b7b-92e5a898db83) to find examples in multiple programming languages.
:::
4 changes: 2 additions & 2 deletions docs/api/usd-ln-send.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,6 @@ mutation LnInvoicePaymentSend($input: LnInvoicePaymentInput!) {
</AuthProvider>

:::tip
To test the GraphQL requests further use the GraphQL playground at [api.blink.sv/graphql](https://api.blink.sv/graphql) for mainnet or [api.staging.galoy.io/graphql](https://api.staging.galoy.io/graphql) for staging.
Can also use the [Galoy API Postman collection](https://documenter.getpostman.com/view/29391384/2s9YCAQq3z#ed78e464-9874-4bf7-9b7b-92e5a898db83) to find examples in multiple programming languages.
To test the GraphQL requests further use the GraphQL playground at [api.blink.sv/graphql](https://api.blink.sv/graphql) for mainnet or [api.staging.galoy.io/graphql](https://api.staging.galoy.io/graphql) for staging.<br />
Check out the [Galoy API Postman collection](https://documenter.getpostman.com/view/29391384/2s9YCAQq3z#ed78e464-9874-4bf7-9b7b-92e5a898db83) to find examples in multiple programming languages.
:::
4 changes: 2 additions & 2 deletions docs/api/usd-onchain-receive.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,6 @@ query Me {
</AuthProvider>

:::tip
To test the GraphQL requests further use the GraphQL playground at [api.blink.sv/graphql](https://api.blink.sv/graphql) for mainnet or [api.staging.galoy.io/graphql](https://api.staging.galoy.io/graphql) for staging.
Can also use the [Galoy API Postman collection](https://documenter.getpostman.com/view/29391384/2s9YCAQq3z#ed78e464-9874-4bf7-9b7b-92e5a898db83) to find examples in multiple programming languages.
To test the GraphQL requests further use the GraphQL playground at [api.blink.sv/graphql](https://api.blink.sv/graphql) for mainnet or [api.staging.galoy.io/graphql](https://api.staging.galoy.io/graphql) for staging.<br />
Check out the [Galoy API Postman collection](https://documenter.getpostman.com/view/29391384/2s9YCAQq3z#ed78e464-9874-4bf7-9b7b-92e5a898db83) to find examples in multiple programming languages.
:::
4 changes: 2 additions & 2 deletions docs/api/usd-onchain-send.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,6 @@ mutation onChainUsdPaymentSendAsBtcDenominated($input: OnChainUsdPaymentSendAsBt
</AuthProvider>

:::tip
To test the GraphQL requests further use the GraphQL playground at [api.blink.sv/graphql](https://api.blink.sv/graphql) for mainnet or [api.staging.galoy.io/graphql](https://api.staging.galoy.io/graphql) for staging.
Can also use the [Galoy API Postman collection](https://documenter.getpostman.com/view/29391384/2s9YCAQq3z#ed78e464-9874-4bf7-9b7b-92e5a898db83) to find examples in multiple programming languages.
To test the GraphQL requests further use the GraphQL playground at [api.blink.sv/graphql](https://api.blink.sv/graphql) for mainnet or [api.staging.galoy.io/graphql](https://api.staging.galoy.io/graphql) for staging.<br />
Check out the [Galoy API Postman collection](https://documenter.getpostman.com/view/29391384/2s9YCAQq3z#ed78e464-9874-4bf7-9b7b-92e5a898db83) to find examples in multiple programming languages.
:::
4 changes: 2 additions & 2 deletions docs/api/webhooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ Example payload sent on a `receive.lightning` event:
The calls to register, list and remove webhooks are made through the GraphQL API as described below.

:::tip
To test the GraphQL requests further use the GraphQL playground at [api.blink.sv/graphql](https://api.blink.sv/graphql) for mainnet or [api.staging.galoy.io/graphql](https://api.staging.galoy.io/graphql) for staging.
Can also use the [Galoy API Postman collection](https://documenter.getpostman.com/view/29391384/2s9YCAQq3z#0be26540-d31c-4d0e-b7ac-400fc73bdb80) to find examples in multiple programming languages.
To test the GraphQL requests further use the GraphQL playground at [api.blink.sv/graphql](https://api.blink.sv/graphql) for mainnet or [api.staging.galoy.io/graphql](https://api.staging.galoy.io/graphql) for staging.<br />
Check out the [Galoy API Postman collection](https://documenter.getpostman.com/view/29391384/2s9YCAQq3z#0be26540-d31c-4d0e-b7ac-400fc73bdb80) to find examples in multiple programming languages.
:::

## Add a callback endpoint
Expand Down
3 changes: 2 additions & 1 deletion sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,11 @@ const sidebars = {
},
],
},
'api/pagination',
'api/webhooks',
'api/errors',
],
},
'api/webhooks',
'api/postman',
'api/learn-more'
],
Expand Down

0 comments on commit 21e3d9e

Please sign in to comment.