@@ -69,40 +69,27 @@ The Geo testnet contains public data that you can query immediately without any
6969- ** No authentication required** for public data queries.
7070- All examples below use the Geo testnet space ID: ` 3f32353d-3b27-4a13-b71a-746f06e1f7db `
7171
72- Each section below includes the relevant ` schema.ts ` , ` mapping.ts ` , and a query example.
72+ Each section below includes the relevant ` schema.ts ` and a query example.
7373
7474### Projects Example
7575
7676** Schema Definition:**
7777
7878``` typescript
7979// app/schema.ts
80- import { Entity , Type } from " @graphprotocol/hypergraph" ;
81-
82- export class Project extends Entity .Class <Project >(" Project" )({
83- name: Type .String ,
84- description: Type .optional (Type .String ),
85- xUrl: Type .optional (Type .String ),
86- }) {}
87- ```
88-
89- ** Mapping Definition:**
80+ import { Entity , Type , Id } from " @graphprotocol/hypergraph" ;
9081
91- ``` typescript
92- // app/mapping.ts
93- import type { Mapping } from ' @graphprotocol/hypergraph' ;
94- import { Id } from ' @graphprotocol/hypergraph' ;
95-
96- export const mapping: Mapping .Mapping = {
97- Project: {
98- typeIds: [Id (' 484a18c5-030a-499c-b0f2-ef588ff16d50' )],
82+ export const Project = Entity .Schema (
83+ { name: Type .String , description: Type .optional (Type .String ), xUrl: Type .optional (Type .String ) },
84+ {
85+ types: [Id (' 484a18c5-030a-499c-b0f2-ef588ff16d50' )],
9986 properties: {
10087 name: Id (' a126ca53-0c8e-48d5-b888-82c734c38935' ),
10188 description: Id (' 9b1f76ff-9711-404c-861e-59dc3fa7d037' ),
10289 x: Id (' 0d625978-4b3c-4b57-a86f-de45c997c73c' ),
10390 },
10491 },
105- } ;
92+ ) ;
10693```
10794
10895** Query Example:**
@@ -171,32 +158,18 @@ export default function ProjectsExample() {
171158// app/schema.ts
172159import { Entity , Type } from " @graphprotocol/hypergraph" ;
173160
174- export class Dapp extends Entity .Class <Dapp >(" Dapp" )({
175- name: Type .String ,
176- description: Type .optional (Type .String ),
177- xUrl: Type .optional (Type .String ),
178- githubUrl: Type .optional (Type .String ),
179- }) {}
180- ```
181-
182- ** Mapping Definition:**
183-
184- ``` typescript
185- // app/mapping.ts
186- import type { Mapping } from ' @graphprotocol/hypergraph' ;
187- import { Id } from ' @graphprotocol/hypergraph' ;
188-
189- export const mapping: Mapping .Mapping = {
190- Dapp: {
191- typeIds: [Id (' 8ca136d0-698a-4bbf-a76b-8e2741b2dc8c' )],
161+ export const Dapp = Entity .Schema (
162+ { name: Type .String , description: Type .optional (Type .String ), xUrl: Type .optional (Type .String ), githubUrl: Type .optional (Type .String ) },
163+ {
164+ types: [Id (' 8ca136d0-698a-4bbf-a76b-8e2741b2dc8c' )],
192165 properties: {
193166 name: Id (' a126ca53-0c8e-48d5-b888-82c734c38935' ),
194167 description: Id (' 9b1f76ff-9711-404c-861e-59dc3fa7d037' ),
195168 x: Id (' 0d625978-4b3c-4b57-a86f-de45c997c73c' ),
196169 github: Id (' 9eedefa8-60ae-4ac1-9a04-805054a4b094' ),
197170 },
198171 },
199- } ;
172+ ) ;
200173```
201174
202175** Query Example:**
@@ -269,55 +242,43 @@ export default function DappsExample() {
269242
270243``` typescript
271244// app/schema.ts
272- import { Entity , Type } from " @graphprotocol/hypergraph" ;
273-
274- export class Investor extends Entity .Class <Investor >(" Investor" )({
275- name: Type .String ,
276- }) {}
277-
278- export class FundingStage extends Entity .Class <FundingStage >(" FundingStage" )({
279- name: Type .String ,
280- }) {}
281-
282- export class InvestmentRound extends Entity .Class <InvestmentRound >(
283- " InvestmentRound"
284- )({
285- name: Type .String ,
286- raisedAmount: Type .optional (Type .Number ),
287- investors: Type .Relation (Investor ),
288- fundingStages: Type .Relation (FundingStage ),
289- }) {}
290- ```
245+ import { Entity , Type , Id } from " @graphprotocol/hypergraph" ;
291246
292- ** Mapping Definition:**
293-
294- ``` typescript
295- // app/mapping.ts
296- import type { Mapping } from ' @graphprotocol/hypergraph' ;
297- import { Id } from ' @graphprotocol/hypergraph' ;
298-
299- export const mapping: Mapping .Mapping = {
300- Investor: {
301- typeIds: [Id (' 331aea18-973c-4adc-8f53-614f598d262d' )],
247+ export const Investor = Entity .Schema (
248+ { name: Type .String },
249+ {
250+ types: [Id (' 331aea18-973c-4adc-8f53-614f598d262d' )],
302251 properties: { name: Id (' a126ca53-0c8e-48d5-b888-82c734c38935' ) },
303252 },
304- FundingStage: {
305- typeIds: [Id (' 8d35d217-3fa1-4686-b74f-fcb3e9438067' )],
253+ );
254+
255+ export const FundingStage = Entity .Schema (
256+ { name: Type .String },
257+ {
258+ types: [Id (' 8d35d217-3fa1-4686-b74f-fcb3e9438067' )],
306259 properties: { name: Id (' a126ca53-0c8e-48d5-b888-82c734c38935' ) },
307260 },
308- InvestmentRound: {
309- typeIds: [Id (' 8f03f4c9-59e4-44a8-a625-c0a40b1ff330' )],
261+ );
262+
263+ export const InvestmentRound = Entity .Schema (
264+ {
265+ name: Type .String ,
266+ raisedAmount: Type .optional (Type .Number ),
267+ investors: Type .Relation (Investor ),
268+ fundingStages: Type .Relation (FundingStage ),
269+ raisedBy: Type .Relation (Project ),
270+ },
271+ {
272+ types: [Id (' 8f03f4c9-59e4-44a8-a625-c0a40b1ff330' )],
310273 properties: {
311274 name: Id (' a126ca53-0c8e-48d5-b888-82c734c38935' ),
312275 raisedAmount: Id (' 16781706-dd9c-48bf-913e-cdf18b56034f' ),
313- },
314- relations: {
315276 investors: Id (' 9b8a610a-fa35-486e-a479-e253dbdabb4f' ),
316277 fundingStages: Id (' e278c3d4-78b9-4222-b272-5a39a8556bd2' ),
317278 raisedBy: Id (' b4878d1a-0609-488d-b8a6-e19862d6b62f' ),
318279 },
319280 },
320- } ;
281+ ) ;
321282```
322283
323284** Query Example:**
@@ -402,33 +363,19 @@ export default function InvestmentRoundsExample() {
402363
403364``` typescript
404365// app/schema.ts
405- import { Entity , Type } from " @graphprotocol/hypergraph" ;
366+ import { Entity , Type , Id } from " @graphprotocol/hypergraph" ;
406367
407- export class Asset extends Entity .Class <Asset >(" Asset" )({
408- name: Type .String ,
409- symbol: Type .optional (Type .String ),
410- blockchainAddress: Type .optional (Type .String ),
411- }) {}
412- ```
413-
414- ** Mapping Definition:**
415-
416- ``` typescript
417- // app/mapping.ts
418- import type { Mapping } from ' @graphprotocol/hypergraph' ;
419- import { Id } from ' @graphprotocol/hypergraph' ;
420-
421- export const mapping: Mapping .Mapping = {
422- Asset: {
423- typeIds: [Id (' f8780a80-c238-4a2a-96cb-567d88b1aa63' )],
368+ export const Asset = Entity .Schema (
369+ { name: Type .String , symbol: Type .optional (Type .String ), blockchainAddress: Type .optional (Type .String ) },
370+ {
371+ types: [Id (' f8780a80-c238-4a2a-96cb-567d88b1aa63' )],
424372 properties: {
425373 name: Id (' a126ca53-0c8e-48d5-b888-82c734c38935' ),
426374 symbol: Id (' ace1e96c-9b83-47b4-bd33-1d302ec0a0f5' ),
427375 blockchainAddress: Id (' 56b5944f-f059-48d1-b0fa-34abe84219da' ),
428376 },
429377 },
430- };
431-
378+ );
432379```
433380
434381** Query Example:**
0 commit comments