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
2 changes: 1 addition & 1 deletion apps/events/src/components/todo/todos-local.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Button } from '../ui/button';
export const TodosLocal = () => {
const updateEntity = useUpdateEntity(Todo2);
const hardDeleteEntity = useHardDeleteEntity();
const { data: todosLocalData, deleted: deletedTodosLocalData } = useQuery(Todo2, { mode: 'local' });
const { data: todosLocalData, deleted: deletedTodosLocalData } = useQuery(Todo2, { mode: 'private' });

return (
<>
Expand Down
4 changes: 2 additions & 2 deletions apps/events/src/components/todos-read-only-filter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { useQuery } from '@graphprotocol/hypergraph-react';
import { Todo } from '../schema';

export const TodosReadOnlyFilter = () => {
const { data: todosCompleted } = useQuery(Todo, { mode: 'local', filter: { completed: { is: true } } });
const { data: todosCompleted } = useQuery(Todo, { mode: 'private', filter: { completed: { is: true } } });
const { data: todosNotCompleted } = useQuery(Todo, {
mode: 'local',
mode: 'private',
filter: { completed: { is: false } },
});

Expand Down
2 changes: 1 addition & 1 deletion apps/events/src/components/todos-read-only.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useQuery } from '@graphprotocol/hypergraph-react';
import { Todo } from '../schema';

export const TodosReadOnly = () => {
const { data: todos } = useQuery(Todo, { mode: 'local' });
const { data: todos } = useQuery(Todo, { mode: 'private' });

return (
<>
Expand Down
4 changes: 2 additions & 2 deletions apps/events/src/components/todos.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import { Button } from './ui/button';
import { Input } from './ui/input';

export const Todos = () => {
const { data: todos } = useQuery(Todo, { mode: 'local', include: { assignees: {} } });
const { data: users } = useQuery(User, { mode: 'local' });
const { data: todos } = useQuery(Todo, { mode: 'private', include: { assignees: {} } });
const { data: users } = useQuery(User, { mode: 'private' });
const createEntity = useCreateEntity(Todo);
const updateEntity = useUpdateEntity(Todo);
const deleteEntity = useDeleteEntity();
Expand Down
2 changes: 1 addition & 1 deletion apps/events/src/components/users.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Input } from './ui/input.js';
import { UserEntry } from './user-entry.js';

export const Users = () => {
const { data: users } = useQuery(User, { mode: 'local' });
const { data: users } = useQuery(User, { mode: 'private' });
const createEntity = useCreateEntity(User);
const [newUserName, setNewUserName] = useState('');

Expand Down
2 changes: 1 addition & 1 deletion apps/events/src/components/users/users-local.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Button } from '../ui/button';

export const UsersLocal = () => {
const hardDeleteEntity = useHardDeleteEntity();
const { data: usersLocalData, deleted: deletedUsersLocalData } = useQuery(User, { mode: 'local' });
const { data: usersLocalData, deleted: deletedUsersLocalData } = useQuery(User, { mode: 'private' });

return (
<>
Expand Down
6 changes: 3 additions & 3 deletions packages/hypergraph-react/src/use-query.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { parseResult, useQueryPublic } from './internal/use-query-public.js';
import type { DiffEntry, PublishDiffInfo } from './types.js';

type QueryParams<S extends Entity.AnyNoContext> = {
mode?: 'merged' | 'public' | 'local';
mode?: 'merged' | 'public' | 'private';
filter?: { [K in keyof Schema.Schema.Type<S>]?: Entity.EntityFieldFilter<Schema.Schema.Type<S>[K]> } | 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;
Expand Down Expand Up @@ -148,7 +148,7 @@ const preparePublishDummy = () => undefined;
export function useQuery<const S extends Entity.AnyNoContext>(type: S, params?: QueryParams<S>) {
const { mode = 'merged', filter, include } = params ?? {};
const publicResult = useQueryPublic(type, { enabled: mode === 'public' || mode === 'merged', include });
const localResult = useQueryLocal(type, { enabled: mode === 'local' || mode === 'merged', filter, include });
const localResult = useQueryLocal(type, { enabled: mode === 'private' || mode === 'merged', filter, include });
const mapping = useSelector(store, (state) => state.context.mapping);
const generateCreateOps = useGenerateCreateOps(type, mode === 'merged');
const generateUpdateOps = useGenerateUpdateOps(type, mode === 'merged');
Expand All @@ -168,7 +168,7 @@ export function useQuery<const S extends Entity.AnyNoContext>(type: S, params?:
};
}

if (mode === 'local') {
if (mode === 'private') {
return {
...publicResult,
data: localResult.entities,
Expand Down
Loading