Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/new-teams-dig.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@graphprotocol/hypergraph-react": patch
---

fix type for useQuery filter option to allwo for or/not operators

4 changes: 1 addition & 3 deletions apps/events/src/components/playground.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ export const Playground = ({ spaceId }: { spaceId: string }) => {
},
},
// filter: {
// name: {
// startsWith: 'test',
// },
// or: [{ name: { startsWith: 'test' } }, { name: { startsWith: 'ETH' } }],
// },
first: 100,
space: spaceId,
Expand Down
6 changes: 5 additions & 1 deletion apps/events/src/components/todos.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ import { Button } from './ui/button';
import { Input } from './ui/input';

export const Todos = () => {
const { data: todos } = useQuery(Todo, { mode: 'private', include: { assignees: {} } });
const { data: todos } = useQuery(Todo, {
mode: 'private',
include: { assignees: {} },
// filter: { or: [{ name: { startsWith: 'aa' } }, { name: { is: 'sdasd' } }] },
});
const { data: users } = useQuery(User, { mode: 'private' });
const { ready: spaceReady } = useSpace({ mode: 'private' });
const createEntity = useCreateEntity(Todo);
Expand Down
3 changes: 0 additions & 3 deletions apps/events/src/mapping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ export const mapping: Mapping = {
typeIds: [Id('bffa181e-a333-495b-949c-57f2831d7eca')],
properties: {
name: Id('c9c79675-850a-42c5-bbbd-9e5c55d3f4e7'),
created: Id('f8df1caf-14b4-4c1e-85fb-4e97f7d7070a'),
},
},
Todo: {
Expand Down Expand Up @@ -54,8 +53,6 @@ export const mapping: Mapping = {
properties: {
name: Id('a126ca53-0c8e-48d5-b888-82c734c38935'),
description: Id('9b1f76ff-9711-404c-861e-59dc3fa7d037'),
createdAt: Id('e2e6906b-d2b6-48d2-8aa2-54e8b29f6933'),
updatedAt: Id('2e877fe0-a504-4ea0-b43c-210d011db434'),
},
relations: {
sponsors: Id('6860bfac-f703-4289-b789-972d0aaf3abe'),
Expand Down
5 changes: 1 addition & 4 deletions apps/events/src/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Entity, Type } from '@graphprotocol/hypergraph';

export class User extends Entity.Class<User>('User')({
name: Type.String,
created: Type.Date,
}) {}

export class Todo extends Entity.Class<Todo>('Todo')({
Expand Down Expand Up @@ -33,10 +32,8 @@ export class Company extends Entity.Class<Company>('Company')({

export class Event extends Entity.Class<Event>('Event')({
name: Type.String,
description: Type.String,
description: Type.optional(Type.String),
sponsors: Type.Relation(Company),
createdAt: Type.Date,
updatedAt: Type.Date,
}) {}

export class Todo3 extends Entity.Class<Todo3>('Todo3')({
Expand Down
2 changes: 1 addition & 1 deletion packages/hypergraph-react/src/HypergraphSpaceContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export function useHardDeleteEntity(options?: { space?: string }) {
type QueryParams<S extends Entity.AnyNoContext> = {
space?: string | undefined;
enabled: boolean;
filter?: { [K in keyof Schema.Schema.Type<S>]?: Entity.EntityFieldFilter<Schema.Schema.Type<S>[K]> } | undefined;
filter?: Entity.EntityFilter<Schema.Schema.Type<S>> | undefined;
include?: { [K in keyof Schema.Schema.Type<S>]?: Record<string, Record<string, never>> } | undefined;
};

Expand Down
2 changes: 1 addition & 1 deletion packages/hypergraph-react/src/internal/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type * as Schema from 'effect/Schema';
export type QueryPublicParams<S extends Entity.AnyNoContext> = {
enabled: boolean;
space?: string | undefined;
filter?: { [K in keyof Schema.Schema.Type<S>]?: Entity.EntityFieldFilter<Schema.Schema.Type<S>[K]> } | undefined;
filter?: Entity.EntityFilter<Schema.Schema.Type<S>> | undefined;
// TODO: for multi-level nesting it should only allow the allowed properties instead of Record<string, Record<string, never>>
include?: { [K in keyof Schema.Schema.Type<S>]?: Record<string, Record<string, never>> } | undefined;
first?: number | undefined;
Expand Down
2 changes: 1 addition & 1 deletion packages/hypergraph-react/src/use-query.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useQueryPublic } from './internal/use-query-public.js';

type QueryParams<S extends Entity.AnyNoContext> = {
mode: 'public' | 'private';
filter?: { [K in keyof Schema.Schema.Type<S>]?: Entity.EntityFieldFilter<Schema.Schema.Type<S>[K]> } | undefined;
filter?: Entity.EntityFilter<Schema.Schema.Type<S>> | undefined;
// TODO: for multi-level nesting it should only allow the allowed properties instead of Record<string, Record<string, never>>
include?: { [K in keyof Schema.Schema.Type<S>]?: Record<string, Record<string, never>> } | undefined;
space?: string | undefined;
Expand Down
Loading