Skip to content

Commit e809170

Browse files
committed
migrate EntitySchema to Entity.Schema
1 parent 006aeeb commit e809170

File tree

13 files changed

+72
-69
lines changed

13 files changed

+72
-69
lines changed

.changeset/icy-emus-tap.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export class User extends Entity.Class<User>('User')({
1515

1616
After:
1717
```ts
18-
export const User = EntitySchema(
18+
export const User = Entity.Schema(
1919
{ name: Type.String },
2020
{
2121
types: [Id('bffa181e-a333-495b-949c-57f2831d7eca')],

apps/events/src/schema.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { EntitySchema, Id, Type } from '@graphprotocol/hypergraph';
1+
import { Entity, Id, Type } from '@graphprotocol/hypergraph';
22

3-
export const User = EntitySchema(
3+
export const User = Entity.Schema(
44
{ name: Type.String },
55
{
66
types: [Id('bffa181e-a333-495b-949c-57f2831d7eca')],
@@ -10,7 +10,7 @@ export const User = EntitySchema(
1010
},
1111
);
1212

13-
export const Todo = EntitySchema(
13+
export const Todo = Entity.Schema(
1414
{
1515
name: Type.String,
1616
completed: Type.Boolean,
@@ -26,7 +26,7 @@ export const Todo = EntitySchema(
2626
},
2727
);
2828

29-
export const Todo2 = EntitySchema(
29+
export const Todo2 = Entity.Schema(
3030
{
3131
name: Type.String,
3232
checked: Type.Boolean,
@@ -50,7 +50,7 @@ export const Todo2 = EntitySchema(
5050
},
5151
);
5252

53-
export const JobOffer = EntitySchema(
53+
export const JobOffer = Entity.Schema(
5454
{
5555
name: Type.String,
5656
salary: Type.Number,
@@ -64,7 +64,7 @@ export const JobOffer = EntitySchema(
6464
},
6565
);
6666

67-
export const Company = EntitySchema(
67+
export const Company = Entity.Schema(
6868
{
6969
name: Type.String,
7070
jobOffers: Type.Relation(JobOffer),
@@ -78,7 +78,7 @@ export const Company = EntitySchema(
7878
},
7979
);
8080

81-
export const Event = EntitySchema(
81+
export const Event = Entity.Schema(
8282
{
8383
name: Type.String,
8484
description: Type.optional(Type.String),
@@ -94,7 +94,7 @@ export const Event = EntitySchema(
9494
},
9595
);
9696

97-
export const Image = EntitySchema(
97+
export const Image = Entity.Schema(
9898
{
9999
url: Type.String,
100100
},
@@ -106,7 +106,7 @@ export const Image = EntitySchema(
106106
},
107107
);
108108

109-
export const Project = EntitySchema(
109+
export const Project = Entity.Schema(
110110
{
111111
name: Type.String,
112112
description: Type.optional(Type.String),

apps/privy-login-example/src/schema.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { EntitySchema, Id, Type } from '@graphprotocol/hypergraph';
1+
import { Entity, Id, Type } from '@graphprotocol/hypergraph';
22

3-
export const User = EntitySchema(
3+
export const User = Entity.Schema(
44
{ name: Type.String },
55
{
66
types: [Id('bffa181e-a333-495b-949c-57f2831d7eca')],
@@ -10,7 +10,7 @@ export const User = EntitySchema(
1010
},
1111
);
1212

13-
export const Todo = EntitySchema(
13+
export const Todo = Entity.Schema(
1414
{
1515
name: Type.String,
1616
completed: Type.Boolean,
@@ -26,7 +26,7 @@ export const Todo = EntitySchema(
2626
},
2727
);
2828

29-
export const Todo2 = EntitySchema(
29+
export const Todo2 = Entity.Schema(
3030
{
3131
name: Type.String,
3232
checked: Type.Boolean,
@@ -50,7 +50,7 @@ export const Todo2 = EntitySchema(
5050
},
5151
);
5252

53-
export const JobOffer = EntitySchema(
53+
export const JobOffer = Entity.Schema(
5454
{
5555
name: Type.String,
5656
salary: Type.Number,
@@ -64,7 +64,7 @@ export const JobOffer = EntitySchema(
6464
},
6565
);
6666

67-
export const Company = EntitySchema(
67+
export const Company = Entity.Schema(
6868
{
6969
name: Type.String,
7070
jobOffers: Type.Relation(JobOffer),
@@ -78,7 +78,7 @@ export const Company = EntitySchema(
7878
},
7979
);
8080

81-
export const Event = EntitySchema(
81+
export const Event = Entity.Schema(
8282
{
8383
name: Type.String,
8484
description: Type.optional(Type.String),
@@ -94,7 +94,7 @@ export const Event = EntitySchema(
9494
},
9595
);
9696

97-
export const Image = EntitySchema(
97+
export const Image = Entity.Schema(
9898
{
9999
url: Type.String,
100100
},
@@ -106,7 +106,7 @@ export const Image = EntitySchema(
106106
},
107107
);
108108

109-
export const Project = EntitySchema(
109+
export const Project = Entity.Schema(
110110
{
111111
name: Type.String,
112112
description: Type.optional(Type.String),

apps/template-nextjs/app/schema.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { EntitySchema, Id, Type } from '@graphprotocol/hypergraph';
1+
import { Entity, Id, Type } from '@graphprotocol/hypergraph';
22

3-
export const Image = EntitySchema(
3+
export const Image = Entity.Schema(
44
{
55
url: Type.String,
66
},
@@ -12,7 +12,7 @@ export const Image = EntitySchema(
1212
},
1313
);
1414

15-
export const Project = EntitySchema(
15+
export const Project = Entity.Schema(
1616
{
1717
name: Type.String,
1818
description: Type.optional(Type.String),
@@ -30,7 +30,7 @@ export const Project = EntitySchema(
3030
},
3131
);
3232

33-
export const Dapp = EntitySchema(
33+
export const Dapp = Entity.Schema(
3434
{
3535
name: Type.String,
3636
description: Type.optional(Type.String),
@@ -50,7 +50,7 @@ export const Dapp = EntitySchema(
5050
},
5151
);
5252

53-
export const Investor = EntitySchema(
53+
export const Investor = Entity.Schema(
5454
{
5555
name: Type.String,
5656
},
@@ -62,7 +62,7 @@ export const Investor = EntitySchema(
6262
},
6363
);
6464

65-
export const FundingStage = EntitySchema(
65+
export const FundingStage = Entity.Schema(
6666
{
6767
name: Type.String,
6868
},
@@ -74,7 +74,7 @@ export const FundingStage = EntitySchema(
7474
},
7575
);
7676

77-
export const InvestmentRound = EntitySchema(
77+
export const InvestmentRound = Entity.Schema(
7878
{
7979
name: Type.String,
8080
raisedAmount: Type.optional(Type.Number),
@@ -94,7 +94,7 @@ export const InvestmentRound = EntitySchema(
9494
},
9595
);
9696

97-
export const Asset = EntitySchema(
97+
export const Asset = Entity.Schema(
9898
{
9999
name: Type.String,
100100
symbol: Type.optional(Type.String),

apps/template-vite-react/src/schema.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { EntitySchema, Id, Type } from '@graphprotocol/hypergraph';
1+
import { Entity, Id, Type } from '@graphprotocol/hypergraph';
22

3-
export const Image = EntitySchema(
3+
export const Image = Entity.Schema(
44
{
55
url: Type.String,
66
},
@@ -12,7 +12,7 @@ export const Image = EntitySchema(
1212
},
1313
);
1414

15-
export const Project = EntitySchema(
15+
export const Project = Entity.Schema(
1616
{
1717
name: Type.String,
1818
description: Type.optional(Type.String),
@@ -30,7 +30,7 @@ export const Project = EntitySchema(
3030
},
3131
);
3232

33-
export const Dapp = EntitySchema(
33+
export const Dapp = Entity.Schema(
3434
{
3535
name: Type.String,
3636
description: Type.optional(Type.String),
@@ -50,7 +50,7 @@ export const Dapp = EntitySchema(
5050
},
5151
);
5252

53-
export const Investor = EntitySchema(
53+
export const Investor = Entity.Schema(
5454
{
5555
name: Type.String,
5656
},
@@ -62,7 +62,7 @@ export const Investor = EntitySchema(
6262
},
6363
);
6464

65-
export const FundingStage = EntitySchema(
65+
export const FundingStage = Entity.Schema(
6666
{
6767
name: Type.String,
6868
},
@@ -74,7 +74,7 @@ export const FundingStage = EntitySchema(
7474
},
7575
);
7676

77-
export const InvestmentRound = EntitySchema(
77+
export const InvestmentRound = Entity.Schema(
7878
{
7979
name: Type.String,
8080
raisedAmount: Type.optional(Type.Number),
@@ -94,7 +94,7 @@ export const InvestmentRound = EntitySchema(
9494
},
9595
);
9696

97-
export const Asset = EntitySchema(
97+
export const Asset = Entity.Schema(
9898
{
9999
name: Type.String,
100100
symbol: Type.optional(Type.String),

packages/hypergraph-react/test/HypergraphSpaceContext.test.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Repo } from '@automerge/automerge-repo';
22
import { RepoContext } from '@automerge/automerge-repo-react-hooks';
3-
import { type Entity, EntitySchema, Id, store, Type } from '@graphprotocol/hypergraph';
3+
import { Entity, Id, store, Type } from '@graphprotocol/hypergraph';
44
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
55
import '@testing-library/jest-dom/vitest';
66
import { act, cleanup, renderHook, waitFor } from '@testing-library/react';
@@ -18,7 +18,7 @@ afterEach(() => {
1818
});
1919

2020
describe('HypergraphSpaceContext', () => {
21-
const Person = EntitySchema(
21+
const Person = Entity.Schema(
2222
{
2323
name: Type.String,
2424
age: Type.Number,
@@ -32,7 +32,7 @@ describe('HypergraphSpaceContext', () => {
3232
},
3333
);
3434

35-
const User = EntitySchema(
35+
const User = Entity.Schema(
3636
{
3737
name: Type.String,
3838
email: Type.String,
@@ -46,7 +46,7 @@ describe('HypergraphSpaceContext', () => {
4646
},
4747
);
4848

49-
const Event = EntitySchema(
49+
const Event = Entity.Schema(
5050
{
5151
name: Type.String,
5252
},

packages/hypergraph-react/test/internal/translate-filter-to-graphql.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { Graph, Id } from '@graphprotocol/grc-20';
2-
import { type Entity, EntitySchema, Type } from '@graphprotocol/hypergraph';
2+
import { Entity, Type } from '@graphprotocol/hypergraph';
33
import type * as Schema from 'effect/Schema';
44
import { describe, expect, it } from 'vitest';
55
import { translateFilterToGraphql } from '../../src/internal/translate-filter-to-graphql.js';
66

7-
export const Todo = EntitySchema(
7+
export const Todo = Entity.Schema(
88
{
99
name: Type.String,
1010
completed: Type.Boolean,

packages/hypergraph-react/test/prepare-publish.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Repo } from '@automerge/automerge-repo';
22
import { Graph, Id } from '@graphprotocol/grc-20';
3-
import { type Entity, EntitySchema, store, Type } from '@graphprotocol/hypergraph';
3+
import { Entity, store, Type } from '@graphprotocol/hypergraph';
44
import '@testing-library/jest-dom/vitest';
55
import request from 'graphql-request';
66
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
@@ -20,7 +20,7 @@ afterEach(() => {
2020

2121
describe('preparePublish', () => {
2222
// Test entity classes
23-
const Person = EntitySchema(
23+
const Person = Entity.Schema(
2424
{
2525
name: Type.String,
2626
age: Type.Number,
@@ -42,7 +42,7 @@ describe('preparePublish', () => {
4242
},
4343
);
4444

45-
const Company = EntitySchema(
45+
const Company = Entity.Schema(
4646
{
4747
name: Type.String,
4848
employees: Type.Relation(Person),
@@ -57,7 +57,7 @@ describe('preparePublish', () => {
5757
);
5858

5959
// Entity class for testing optional types
60-
const OptionalFieldsEntity = EntitySchema(
60+
const OptionalFieldsEntity = Entity.Schema(
6161
{
6262
name: Type.String, // required field
6363
optionalNumber: Type.optional(Type.Number),

packages/hypergraph/src/entity/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ export * from './delete.js';
33
export * from './findMany.js';
44
export * from './findOne.js';
55
export * from './removeRelation.js';
6+
export * from './schema.js';
67
export * from './types.js';
78
export * from './update.js';

0 commit comments

Comments
 (0)