Skip to content

Commit cb54727

Browse files
authored
rename Type.Text to Type.String (#411)
1 parent c059304 commit cb54727

File tree

16 files changed

+86
-78
lines changed

16 files changed

+86
-78
lines changed

.changeset/bitter-dancers-lead.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"@graphprotocol/hypergraph-react": minor
3+
"@graphprotocol/hypergraph": minor
4+
---
5+
6+
rename Type.Text to Type.String
7+
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { Entity, Type } from '@graphprotocol/hypergraph';
22

33
export class Address extends Entity.Class<Address>('Address')({
4-
name: Type.Text,
5-
description: Type.Text,
4+
name: Type.String,
5+
description: Type.String,
66
}) {}
77

88
export class Project extends Entity.Class<Project>('Project')({
9-
name: Type.Text,
9+
name: Type.String,
1010
}) {}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { Entity, Type } from '@graphprotocol/hypergraph';
22

33
export class Address extends Entity.Class<Address>('Address')({
4-
name: Type.Text,
5-
description: Type.Text,
4+
name: Type.String,
5+
description: Type.String,
66
}) {}
77

88
export class Project extends Entity.Class<Project>('Project')({
9-
name: Type.Text,
9+
name: Type.String,
1010
}) {}

apps/events/src/schema.ts

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

33
export class User extends Entity.Class<User>('User')({
4-
name: Type.Text,
4+
name: Type.String,
55
}) {}
66

77
export class Todo extends Entity.Class<Todo>('Todo')({
8-
name: Type.Text,
8+
name: Type.String,
99
completed: Type.Boolean,
1010
assignees: Type.Relation(User),
1111
}) {}
1212

1313
export class Todo2 extends Entity.Class<Todo2>('Todo2')({
14-
name: Type.Text,
14+
name: Type.String,
1515
checked: Type.Boolean,
1616
assignees: Type.Relation(User),
1717
due: Type.Date,
1818
amount: Type.Number,
1919
point: Type.Point,
20-
website: Type.Text,
20+
website: Type.String,
2121
}) {}
2222

2323
export class JobOffer extends Entity.Class<JobOffer>('JobOffer')({
24-
name: Type.Text,
24+
name: Type.String,
2525
salary: Type.Number,
2626
}) {}
2727

2828
export class Company extends Entity.Class<Company>('Company')({
29-
name: Type.Text,
30-
// address: Type.Text,
29+
name: Type.String,
30+
// address: Type.String,
3131
jobOffers: Type.Relation(JobOffer),
3232
}) {}
3333

3434
export class Event extends Entity.Class<Event>('Event')({
35-
name: Type.Text,
36-
description: Type.optional(Type.Text),
35+
name: Type.String,
36+
description: Type.optional(Type.String),
3737
sponsors: Type.Relation(Company),
3838
}) {}

docs/docs/filtering-query-results.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Note: Filtering is not yet supported for public data.
88

99
```tsx
1010
export class Event extends Entity.Class<Event>("Event")({
11-
name: Type.Text,
11+
name: Type.String,
1212
cancelled: Type.Boolean,
1313
}) {}
1414

@@ -29,7 +29,7 @@ The filter API supports different filters for different property types and offer
2929
exists: true/false, // filter by existence of the property
3030
}
3131

32-
// text filter
32+
// string filter
3333
{
3434
is: "text", // exact match
3535
contains: "text",
@@ -131,7 +131,7 @@ const { data } = useQuery(Person, {
131131
```tsx
132132
// schema
133133
export class Todo extends Entity.Class<Todo2>('Todo')({
134-
name: Type.Text,
134+
name: Type.String,
135135
checked: Type.Boolean,
136136
assignees: Type.Relation(User),
137137
})
@@ -174,7 +174,7 @@ const { data } = useQuery(Person, {
174174
```tsx
175175
// schema
176176
export class Todo extends Entity.Class<Todo2>('Todo')({
177-
name: Type.Text,
177+
name: Type.String,
178178
checked: Type.Boolean,
179179
assignees: Type.Relation(User, {
180180
entity: {

docs/docs/schema.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ Here is an example of a schema for an Event app with the properties `name` and `
1010
import { Entity, Type } from '@graphprotocol/hypergraph';
1111

1212
export class Event extends Entity.Class<Event>('Event')({
13-
name: Type.Text,
14-
description: Type.Text,
13+
name: Type.String,
14+
description: Type.String,
1515
}) {}
1616
```
1717

@@ -23,19 +23,19 @@ In order to define relations between Types, you can use the `Type.Relation` type
2323
import { Entity, Type } from '@graphprotocol/hypergraph';
2424

2525
export class Company extends Entity.Class<Company>('Company')({
26-
name: Type.Text,
26+
name: Type.String,
2727
}) {}
2828

2929
export class Event extends Entity.Class<Event>('Event')({
30-
name: Type.Text,
31-
description: Type.Text,
30+
name: Type.String,
31+
description: Type.String,
3232
sponsors: Type.Relation(Company),
3333
}) {}
3434
```
3535

3636
## Available Types
3737

38-
- `Type.Text` (string)
38+
- `Type.String` (string)
3939
- `Type.Number` (number)
4040
- `Type.Date` (date)
4141
- `Type.Boolean` (boolean)
@@ -48,7 +48,7 @@ Example:
4848
import { Entity, Type } from '@graphprotocol/hypergraph';
4949

5050
export class Company extends Entity.Class<Company>('Company')({
51-
name: Type.Text,
51+
name: Type.String,
5252
employees: Type.Number,
5353
founded: Type.Date,
5454
active: Type.Boolean,
@@ -64,8 +64,8 @@ You can make a field optional by wrapping it in `Type.optional`.
6464
import { Entity, Type } from '@graphprotocol/hypergraph';
6565

6666
export class Company extends Entity.Class<Company>('Company')({
67-
name: Type.Text,
68-
description: Type.optional(Type.Text),
67+
name: Type.String,
68+
description: Type.optional(Type.String),
6969
founded: Type.optional(Type.Date),
7070
}) {}
7171
```

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,17 @@ afterEach(() => {
2020

2121
describe('HypergraphSpaceContext', () => {
2222
class Person extends Entity.Class<Person>('Person')({
23-
name: Type.Text,
23+
name: Type.String,
2424
age: Type.Number,
2525
}) {}
2626

2727
class User extends Entity.Class<User>('User')({
28-
name: Type.Text,
29-
email: Type.Text,
28+
name: Type.String,
29+
email: Type.String,
3030
}) {}
3131

3232
class Event extends Entity.Class<Event>('Event')({
33-
name: Type.Text,
33+
name: Type.String,
3434
}) {}
3535

3636
const spaceId = '1e5e39da-a00d-4fd8-b53b-98095337112f';

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,22 @@ afterEach(() => {
2121
describe('preparePublish', () => {
2222
// Test entity classes
2323
class Person extends Entity.Class<Person>('Person')({
24-
name: Type.Text,
24+
name: Type.String,
2525
age: Type.Number,
26-
email: Type.optional(Type.Text),
26+
email: Type.optional(Type.String),
2727
isActive: Type.Boolean,
2828
birthDate: Type.Date,
2929
location: Type.Point,
3030
}) {}
3131

3232
class Company extends Entity.Class<Company>('Company')({
33-
name: Type.Text,
33+
name: Type.String,
3434
employees: Type.Relation(Person),
3535
}) {}
3636

3737
// Entity class for testing optional types
3838
class OptionalFieldsEntity extends Entity.Class<OptionalFieldsEntity>('OptionalFieldsEntity')({
39-
name: Type.Text, // required field
39+
name: Type.String, // required field
4040
optionalNumber: Type.optional(Type.Number),
4141
optionalBoolean: Type.optional(Type.Boolean),
4242
optionalDate: Type.optional(Type.Date),
@@ -323,7 +323,7 @@ describe('preparePublish', () => {
323323

324324
it('should throw error when mapping entry is not found', async () => {
325325
class UnmappedEntity extends Entity.Class<UnmappedEntity>('UnmappedEntity')({
326-
name: Type.Text,
326+
name: Type.String,
327327
}) {}
328328

329329
const entity = {

packages/hypergraph/src/entity/findMany.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import type {
1515
EntityFieldFilter,
1616
EntityFilter,
1717
EntityNumberFilter,
18-
EntityTextFilter,
18+
EntityStringFilter,
1919
} from './types.js';
2020

2121
const documentChangeListener: {
@@ -298,19 +298,19 @@ export function findMany<const S extends AnyNoContext>(
298298

299299
if (typeof fieldValue === 'string') {
300300
if ('startsWith' in fieldFilter) {
301-
const textFilter = fieldFilter as EntityTextFilter;
301+
const textFilter = fieldFilter as EntityStringFilter;
302302
if (textFilter.startsWith !== undefined && !fieldValue.startsWith(textFilter.startsWith)) {
303303
return false;
304304
}
305305
}
306306
if ('endsWith' in fieldFilter) {
307-
const textFilter = fieldFilter as EntityTextFilter;
307+
const textFilter = fieldFilter as EntityStringFilter;
308308
if (textFilter.endsWith !== undefined && !fieldValue.endsWith(textFilter.endsWith)) {
309309
return false;
310310
}
311311
}
312312
if ('contains' in fieldFilter) {
313-
const textFilter = fieldFilter as EntityTextFilter;
313+
const textFilter = fieldFilter as EntityStringFilter;
314314
if (textFilter.contains !== undefined && !fieldValue.includes(textFilter.contains)) {
315315
return false;
316316
}

packages/hypergraph/src/entity/types.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,14 @@ export type EntityNumberFilter = {
5959
or?: EntityNumberFilter[];
6060
};
6161

62-
export type EntityTextFilter = {
62+
export type EntityStringFilter = {
6363
is?: string;
6464
startsWith?: string;
6565
endsWith?: string;
6666
contains?: string;
6767
equals?: string;
68-
not?: EntityTextFilter;
69-
or?: EntityTextFilter[];
68+
not?: EntityStringFilter;
69+
or?: EntityStringFilter[];
7070
};
7171

7272
export type CrossFieldFilter<T> = {

0 commit comments

Comments
 (0)