Skip to content

Commit c277e3a

Browse files
authored
update typesync docs (#479)
1 parent 21efecd commit c277e3a

9 files changed

Lines changed: 32 additions & 55 deletions

File tree

docs/docs/typesync.md

Lines changed: 32 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,50 @@
11
---
22
title: TypeSync
3-
description: To create an app with custom data types.
3+
description: TypeSync is a visual tool that helps you manage your Hypergraph schema and update the schema.ts and mapping.ts for your Hypergraph application.
44
version: 0.0.1
55
tags: [typesync, hypergraph-cli, schema]
66
---
77

88
# 🧬 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)
9+
10+
TypeSync is a visual tool that helps you manage your Hypergraph schema and update the schema.ts and mapping.ts for your Hypergraph application.
1411

1512
## 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-
```
2413

25-
Selecting all the options by pressing `a` followed by `Yes`
14+
TypeSync automatically comes with the `hypergraph` package. Once you have it installed it will be available via:
2615

2716

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
17+
```bash
18+
npx hg typesync --open
19+
# or
20+
pnpm hg typesync --open
21+
bunx hg typesync --open
22+
yarn hg typesync --open
3023
```
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```.
24+
25+
This will start the TypeSync server. You can now access the TypeSync app in your browser at `http://localhost:3000`. The UI will look like this:
26+
3427
![TypeSync Dashboard](../static/img/typesync/typesync_dashboard.png)
3528

29+
The UI is split into two main sections:
30+
- The left side is a list of existing types in the Knowledge Graph to pick from.
31+
- The right side represents the schema you are currently working on.
32+
- At the bottom you can find two buttons:
33+
- `Sync with schema.ts` to sync the current schema to your `schema.ts` file.
34+
- `Publish Schema` to publish the current schema to the Knowledge Graph.
35+
- The top right corner you can find a button to `Sign in to Geo Account` to sign in to your Geo Account. This is a prerequisite to publish your schema to the Knowledge Graph.
36+
37+
## Recommended Flow
38+
39+
1. Design your schema
40+
2. Sync it to your schema.ts file using the `Sync with schema.ts` button
41+
3. Publish your schema to the Knowledge Graph
42+
1. Sign in with Geo Connect. To do so click on the `Sign in to Geo Account` button in the top right corner.
43+
2. In "Connect" select an existing public space or create & select a new public space you want to publish your schema to. Note: Can be any space of your choice and doesn't matter which one.
44+
3. Click the "Publish Schema" button to publish your schema to the Knowledge Graph.
3645

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.
46+
## Best Practices
5847

59-
Example of the generated schema (```src/schema.ts```):
60-
```typescript
61-
import type { Mapping } from '@graphprotocol/hypergraph';
62-
import { Id } from '@graphprotocol/hypergraph';
48+
If there is an existing type ideally use this one and adept it to your needs. This will allow for more interoperability with other applications.
6349

64-
export const mapping: Mapping = {
65-
AcademicYear: {
66-
typeIds: [Id("27e097b7-fba0-4fdd-a264-b0ed70f79e0a")],
67-
properties: {
68-
description: Id("9b1f76ff-9711-404c-861e-59dc3fa7d037"),
69-
name: Id("a126ca53-0c8e-48d5-b888-82c734c38935")
70-
},
71-
},
72-
}
73-
```
50+
For properties prefer existing properties, but in case you need a different type best to create a new property.
-470 KB
Binary file not shown.
-141 KB
Binary file not shown.
-213 KB
Binary file not shown.
-160 KB
Binary file not shown.
-196 KB
Binary file not shown.
-434 KB
Binary file not shown.
-440 KB
Binary file not shown.
731 KB
Loading

0 commit comments

Comments
 (0)