Skip to content

Commit 566d18d

Browse files
authored
feat: Added docs for typesync (#410)
1 parent daedcae commit 566d18d

File tree

10 files changed

+74
-0
lines changed

10 files changed

+74
-0
lines changed

docs/docs/typesync.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
---
2+
title: TypeSync
3+
description: To create an app with custom data types.
4+
version: 0.0.1
5+
tags: [typesync, hypergraph-cli, schema]
6+
---
7+
8+
# 🧬 TypeSync
9+
To create an app with custom data types, you can use the `TypeSync`, fully-functional React application powered by Hypergraph using our scaffolding tool. In just a few minutes, you'll have a local development environment up and running.
10+
## Pre-requisites
11+
- Node.js >= 22
12+
- pnpm >= 10 (Install with `npm install -g pnpm`)
13+
- Git SSH Setup (for cloning the repo)
14+
15+
## Installation
16+
First install the Hypergraph CLI.
17+
```
18+
pnpm install -g @graphprotocol/hypergraph-cli@latest
19+
```
20+
Approve the building scripts by running the following command:
21+
```
22+
pnpm approve-builds -g
23+
```
24+
25+
Selecting all the options by pressing `a` followed by `Yes`
26+
27+
28+
## Launching TypeSync
29+
TypeSync is a visual tool that helps you define your data schema and then generates a complete starter application based on your design. Launch it with
30+
```
31+
hg typesync --open
32+
```
33+
This will start the TypeSync server. You can now access the TypeSync app in your browser at ```http://localhost:3000```.
34+
![TypeSync Dashboard](../static/img/typesync/typesync_dashboard.png)
35+
36+
37+
## Scaffold Your First Application
38+
In the TypeSync Studio:
39+
1. **Create a New Application**: Click on "New App" to start a new application. Give it a name and description.
40+
![Create New App](../static/img/typesync/create_new_app.png)
41+
2. **Browse Your Schema**: Use the Schema Browser to explore existing data types or create new ones.
42+
![Schema Browser](../static/img/typesync/schema_browser.png)
43+
3. **Select Schema**: Choose the data types you want to include in your application. You can select multiple types or create new ones by clicking "Add Type". Click on "Select Template & Generate".
44+
![Select Schema](../static/img/typesync/select_schema.png)
45+
![Add Type](../static/img/typesync/add_type.png)
46+
4. **Generate Application**: After selecting your schema, click on "Generate App". TypeSync will create a complete React application with the selected data types.
47+
![Generate App](../static/img/typesync/generate_app.png)
48+
![App Details](../static/img/typesync/app_details.png)
49+
![App Schema View](../static/img/typesync/app_schema_view.png)
50+
5. **Run Your Application**: Once the app is generated, you can run it locally. Navigate to the generated app directory and run:
51+
```
52+
cd <your-app-name>
53+
pnpm install
54+
pnpm dev
55+
```
56+
This will start the application, and you can view it in your browser at `http://localhost:5173`.
57+
You're all set! You can now start building your application by editing the files in the ```src``` directory. The generated ```src/schema.ts``` file contains the Hypergraph schema you defined in TypeSync.
58+
59+
Example of the generated schema (```src/schema.ts```):
60+
```typescript
61+
import { Id } from '@graphprotocol/grc-20';
62+
import type { Mapping } from '@graphprotocol/typesync/Mapping';
63+
64+
export const mapping: Mapping = {
65+
AcademicYear: {
66+
typeIds: [Id.Id("27e097b7-fba0-4fdd-a264-b0ed70f79e0a")],
67+
properties: {
68+
description: Id.Id("9b1f76ff-9711-404c-861e-59dc3fa7d037"),
69+
name: Id.Id("a126ca53-0c8e-48d5-b888-82c734c38935")
70+
},
71+
},
72+
}
73+
```

docs/sidebars.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const sidebars = {
2121
// { type: 'doc', id: 'faucet', label: '🪙 Testnet Faucet' },
2222
{ type: 'doc', id: 'key-features', label: '🌟 Key Features' },
2323
{ type: 'doc', id: 'core-concepts', label: '🧠 Core Concepts' },
24+
{ type: 'doc', id: 'typesync', label: '🧬 TypeSync' },
2425
{ type: 'doc', id: 'providers', label: '🔗 Providers' },
2526
{ type: 'doc', id: 'authentication', label: '🔗 Authentication' },
2627
{ type: 'doc', id: 'spaces', label: '🏠 Spaces' },
470 KB
Loading
141 KB
Loading
213 KB
Loading
160 KB
Loading
196 KB
Loading
434 KB
Loading
440 KB
Loading
148 KB
Loading

0 commit comments

Comments
 (0)