Skip to content

Commit

Permalink
feat(): backend docs (#16)
Browse files Browse the repository at this point in the history
* feat(): backend docs

* feat(): add examples
  • Loading branch information
mduthey authored Feb 7, 2025
1 parent 3d76d0f commit 1e31d7e
Show file tree
Hide file tree
Showing 6 changed files with 335 additions and 1 deletion.
4 changes: 4 additions & 0 deletions docs/app/backend/_meta.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export default {
schema: '',
example: '',
};
199 changes: 199 additions & 0 deletions docs/app/backend/example/page.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
---
title: GraphQL Examples
sidebarTitle: Example
---
## dapps

### Query
```graphql
query DApps($pageSize: Int, $offset: Int, $search: String) {
dapps(pageSize:$pageSize, offset:$offset, search:$search) {
nodes {
id
name
scope
version
}
pageInfo {
hasPreviousPage
hasNextPage
startCursor
endCursor
}
metadata {
totalNodes
pageSize
}
}
}
```

### Variables
```graphql
{
"pageSize": 4,
"offset": 0,
}
```

### Result
```json
{
"data": {
"dapps": {
"nodes": [
{
"id": "txpipe/asteria",
"name": "asteria",
"scope": "txpipe",
"version": "0.0.0"
}
],
"pageInfo": {
"hasPreviousPage": false,
"hasNextPage": false,
"startCursor": "0",
"endCursor": "0"
},
"metadata": {
"totalNodes": 1,
"pageSize": 1
}
}
}
}
```

## dapp
### Query
```graphql
query dapp($scope: String!, $name: String!) {
dapp(scope: $scope, name: $name) {
id
name
scope
publishedDate
repositoryUrl
blueprintUrl
readme
blueprint {
description
version
license
compilerName
compilerVersion
plutusVersion
validators {
name
datum {
name
schemaName
}
redeemer {
name
schemaName
}
parameters {
name
schemaName
}
}
schemas {
name
schema
}
}
}
}
```

### Variables
```graphql
{
"scope": "txpipe",
"name": "asteria"
}
```

### Result
```json
{
"data": {
"dapp": {
"id": "txpipe/asteria",
"name": "asteria",
"scope": "txpipe",
"publishedDate": 1738871210,
"repositoryUrl": "https://github.com/txpipe/asteria",
"blueprintUrl": "https://github.com/txpipe/asteria/blob/main/onchain/src/plutus.json",
"readme": "# Asteria\n\nA Cardano bot challenge to showcase the capabilities of [...]",
"blueprint": {
"description": "Aiken contracts for project 'txpipe/asteria'",
"version": "0.0.0",
"license": "Apache-2.0",
"compilerName": "Aiken",
"compilerVersion": "v1.1.3+3d77b5c",
"plutusVersion": "v3",
"validators": [
{
"name": "asteria.asteria.spend",
"datum": {
"name": "datum",
"schemaName": "AsteriaTypesAsteriaDatum"
},
"redeemer": {
"name": "redeemer",
"schemaName": "AsteriaTypesAsteriaRedeemer"
},
"parameters": [
{
"name": "admin_token",
"schemaName": "AsteriaTypesAssetClass"
},
{
"name": "ship_mint_lovelace_fee",
"schemaName": "Int"
},
{
"name": "max_asteria_mining",
"schemaName": "Int"
}
]
},
{
"name": "asteria.asteria.else",
"datum": null,
"redeemer": null,
"parameters": [
{
"name": "admin_token",
"schemaName": "AsteriaTypesAssetClass"
},
{
"name": "ship_mint_lovelace_fee",
"schemaName": "Int"
},
{
"name": "max_asteria_mining",
"schemaName": "Int"
}
]
},
[...]
],
"schemas": [
{
"name": "AssetName",
"schema": "{\"title\":\"AssetName\",\"dataType\":\"bytes\"}"
},
{
"name": "Int",
"schema": "{\"dataType\":\"integer\"}"
},
[...]
]
}
}
}
}
```
14 changes: 14 additions & 0 deletions docs/app/backend/page.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
title: Backend
asIndexPage: true
---

## Backend

The backend is a GraphQL server that allows querying and managing DApps. It enables listing all available DApps, retrieving details of a specific DApp, and searching for DApps by name.

Each DApp is associated with a blueprint, which includes key metadata such as its description, version, license, and more. Additionally, every blueprint has a set of validators and schemas that define its structure and validation rules.

This backend provides a flexible and efficient way to access DApp-related data, ensuring developers can fetch exactly what they need with minimal overhead.

For more details on the available queries and data structures, you can refer to the GraphQL schema [here](/backend/schema).
113 changes: 113 additions & 0 deletions docs/app/backend/schema/page.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
---
title: Schema
---

## Types

### Dapp

Represents a decentralized application.

- **id**: `ID!` - Unique identifier.
- **name**: `String!` - Name of the Dapp.
- **scope**: `String!` - Scope of the Dapp.
- **repositoryUrl**: `String!` - URL of the repository.
- **blueprintUrl**: `String!` - URL of the blueprint.
- **publishedDate**: `Int!` - Date of publication (Unix timestamp).
- **readme**: `String!` - Readme content.
- **version**: `String!` - Version of the Dapp.
- **blueprint**: [`DappBlueprint!`](#dappblueprint) - Blueprint details.

### DappBlueprint

Details of the Dapp's blueprint.

- **description**: `String!` - Description of the blueprint.
- **version**: `String!` - Version of the blueprint.
- **license**: `String!` - License information.
- **compilerName**: `String!` - Name of the compiler.
- **compilerVersion**: `String!` - Version of the compiler.
- **plutusVersion**: `String!` - Version of Plutus.
- **validators**: [`[DappValidator!]!`](#dappvalidator) - List of validators.
- **schemas**: [`[DappSchema!]!`](#dappschema) - List of schemas.
- **codegen**: `String!` - Codegen information.

### DappConnection

Connection for paginating Dapps.

- **pageInfo**: [`PageInfo!`](#pageinfo) - Pagination information.
- **edges**: [`[DappEdge!]!`](#dappedge) - List of edges.
- **nodes**: [`[Dapp!]!`](#dapp) - List of nodes (Dapps).
- **metadata**: [`PaginationInfo`](#paginationinfo) - Additional pagination metadata.

### DappEdge

Edge in the Dapp connection.

- **node**: [`Dapp!`](#dapp) - The Dapp node.
- **cursor**: `String!` - Cursor for pagination.

### DappReference

Reference to a Dapp schema.

- **name**: `String` - Name.
- **schemaName**: `String!` - Name of the schema.

### DappSchema

Schema definition for a Dapp.

- **name**: `String!` - Name of the schema.
- **schema**: `String!` - Schema content.

### DappValidator

Validator information for a Dapp.

- **name**: `String!` - Name of the validator.
- **datum**: [`DappReference`](#dappreference) - Reference to the datum schema.
- **redeemer**: [`DappReference`](#dappreference) - Reference to the redeemer schema.
- **parameters**: [`[DappReference!]!`](#dappreference) - List of parameter references.

### PageInfo

Information about pagination.

- **hasPreviousPage**: `Boolean!` - Indicates if there are more items in the previous page.
- **hasNextPage**: `Boolean!` - Indicates if there are more items in the next page.
- **startCursor**: `String` - Cursor for the start of the page.
- **endCursor**: `String` - Cursor for the end of the page.

### PaginationInfo

Additional pagination information.

- **totalNodes**: `Int!` - Total number of nodes.
- **pageSize**: `Int!` - Page size.

## Queries

### dapps

Retrieve a list of Dapps with pagination and/or search.

- **pageSize**: `Int` - Number of items per page.
- **offset**: `Int` - Offset for pagination.
- **search**: `String` - Search term.

Returns: [`DappConnection!`](#dappconnection)

[`See example`](/backend/example#dapps)

### dapp

Retrieve a single Dapp by scope and name.

- **scope**: `String!` - Scope of the Dapp.
- **name**: `String!` - Name of the Dapp.

Returns: [`Dapp`](#dapp)

[`See example`](/backend/example#dapp)
4 changes: 4 additions & 0 deletions docs/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ import 'nextra-theme-docs/style.css';
export const metadata = {
// Define your metadata here
// For more information on metadata API, see: https://nextjs.org/docs/app/building-your-application/optimizing/metadata
title: {
absolute: '',
template: '%s - Telchar Docs',
},
};

const banner = (
Expand Down
2 changes: 1 addition & 1 deletion docs/app/page.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: Docs home - Telchar Docs
title: Telchar Docs
sidebarTitle: Introduction
---

Expand Down

0 comments on commit 1e31d7e

Please sign in to comment.