drizzle-graphql-suite 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +126 -0
- package/package.json +76 -0
- package/packages/client/README.md +236 -0
- package/packages/client/dist/LICENSE +21 -0
- package/packages/client/dist/README.md +236 -0
- package/packages/client/dist/client.d.ts +19 -0
- package/packages/client/dist/entity.d.ts +57 -0
- package/packages/client/dist/errors.d.ts +19 -0
- package/packages/client/dist/index.d.ts +11 -0
- package/packages/client/dist/index.js +439 -0
- package/packages/client/dist/infer.d.ts +86 -0
- package/packages/client/dist/package.json +37 -0
- package/packages/client/dist/query-builder.d.ts +12 -0
- package/packages/client/dist/schema-builder.d.ts +15 -0
- package/packages/client/dist/types.d.ts +45 -0
- package/packages/query/README.md +276 -0
- package/packages/query/dist/LICENSE +21 -0
- package/packages/query/dist/README.md +276 -0
- package/packages/query/dist/index.d.ts +7 -0
- package/packages/query/dist/index.js +172 -0
- package/packages/query/dist/package.json +39 -0
- package/packages/query/dist/provider.d.ts +7 -0
- package/packages/query/dist/test-setup.d.ts +1 -0
- package/packages/query/dist/test-utils.d.ts +40 -0
- package/packages/query/dist/types.d.ts +4 -0
- package/packages/query/dist/useEntity.d.ts +2 -0
- package/packages/query/dist/useEntityInfiniteQuery.d.ts +26 -0
- package/packages/query/dist/useEntityList.d.ts +22 -0
- package/packages/query/dist/useEntityMutation.d.ts +41 -0
- package/packages/query/dist/useEntityQuery.d.ts +21 -0
- package/packages/schema/README.md +348 -0
- package/packages/schema/dist/LICENSE +21 -0
- package/packages/schema/dist/README.md +348 -0
- package/packages/schema/dist/adapters/pg.d.ts +10 -0
- package/packages/schema/dist/adapters/types.d.ts +11 -0
- package/packages/schema/dist/case-ops.d.ts +2 -0
- package/packages/schema/dist/codegen.d.ts +12 -0
- package/packages/schema/dist/data-mappers.d.ts +12 -0
- package/packages/schema/dist/graphql/scalars.d.ts +2 -0
- package/packages/schema/dist/graphql/type-builder.d.ts +7 -0
- package/packages/schema/dist/index.d.ts +26 -0
- package/packages/schema/dist/index.js +1812 -0
- package/packages/schema/dist/package.json +41 -0
- package/packages/schema/dist/schema-builder.d.ts +65 -0
- package/packages/schema/dist/types.d.ts +117 -0
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
// src/provider.tsx
|
|
2
|
+
import { createContext, useContext } from "react";
|
|
3
|
+
import { jsxDEV } from "react/jsx-dev-runtime";
|
|
4
|
+
"use client";
|
|
5
|
+
var GraphQLClientContext = createContext(null);
|
|
6
|
+
function GraphQLProvider({
|
|
7
|
+
client,
|
|
8
|
+
children
|
|
9
|
+
}) {
|
|
10
|
+
return /* @__PURE__ */ jsxDEV(GraphQLClientContext.Provider, {
|
|
11
|
+
value: client,
|
|
12
|
+
children
|
|
13
|
+
}, undefined, false, undefined, this);
|
|
14
|
+
}
|
|
15
|
+
function useGraphQLClient() {
|
|
16
|
+
const client = useContext(GraphQLClientContext);
|
|
17
|
+
if (!client) {
|
|
18
|
+
throw new Error("useGraphQLClient must be used within a <GraphQLProvider>");
|
|
19
|
+
}
|
|
20
|
+
return client;
|
|
21
|
+
}
|
|
22
|
+
// src/useEntity.ts
|
|
23
|
+
import { useMemo } from "react";
|
|
24
|
+
function useEntity(entityName) {
|
|
25
|
+
const client = useGraphQLClient();
|
|
26
|
+
return useMemo(() => client.entity(entityName), [client, entityName]);
|
|
27
|
+
}
|
|
28
|
+
// src/useEntityInfiniteQuery.ts
|
|
29
|
+
import { useInfiniteQuery } from "@tanstack/react-query";
|
|
30
|
+
function useEntityInfiniteQuery(entity, params, options) {
|
|
31
|
+
const queryKey = options?.queryKey ?? [
|
|
32
|
+
"gql",
|
|
33
|
+
"infinite",
|
|
34
|
+
params.select,
|
|
35
|
+
params.where,
|
|
36
|
+
params.orderBy,
|
|
37
|
+
params.pageSize
|
|
38
|
+
];
|
|
39
|
+
return useInfiniteQuery({
|
|
40
|
+
queryKey,
|
|
41
|
+
initialPageParam: 0,
|
|
42
|
+
queryFn: async ({ pageParam = 0 }) => {
|
|
43
|
+
const queryParams = {
|
|
44
|
+
...params,
|
|
45
|
+
limit: params.pageSize,
|
|
46
|
+
offset: pageParam * params.pageSize
|
|
47
|
+
};
|
|
48
|
+
const items = await entity.query(queryParams);
|
|
49
|
+
const count = await entity.count({ where: params.where });
|
|
50
|
+
return {
|
|
51
|
+
items,
|
|
52
|
+
count
|
|
53
|
+
};
|
|
54
|
+
},
|
|
55
|
+
getNextPageParam: (lastPage, allPages) => {
|
|
56
|
+
const totalFetched = allPages.length * params.pageSize;
|
|
57
|
+
return totalFetched < lastPage.count ? allPages.length : undefined;
|
|
58
|
+
},
|
|
59
|
+
enabled: options?.enabled,
|
|
60
|
+
gcTime: options?.gcTime,
|
|
61
|
+
staleTime: options?.staleTime
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
// src/useEntityList.ts
|
|
65
|
+
import { useQuery } from "@tanstack/react-query";
|
|
66
|
+
function useEntityList(entity, params, options) {
|
|
67
|
+
const queryKey = options?.queryKey ?? [
|
|
68
|
+
"gql",
|
|
69
|
+
"list",
|
|
70
|
+
params.select,
|
|
71
|
+
params.where,
|
|
72
|
+
params.orderBy,
|
|
73
|
+
params.limit,
|
|
74
|
+
params.offset
|
|
75
|
+
];
|
|
76
|
+
return useQuery({
|
|
77
|
+
queryKey,
|
|
78
|
+
queryFn: async () => {
|
|
79
|
+
return await entity.query(params);
|
|
80
|
+
},
|
|
81
|
+
enabled: options?.enabled,
|
|
82
|
+
gcTime: options?.gcTime,
|
|
83
|
+
staleTime: options?.staleTime,
|
|
84
|
+
refetchOnWindowFocus: options?.refetchOnWindowFocus
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
// src/useEntityMutation.ts
|
|
88
|
+
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
89
|
+
function useEntityInsert(entity, returning, options) {
|
|
90
|
+
const queryClient = useQueryClient();
|
|
91
|
+
const shouldInvalidate = options?.invalidate !== false;
|
|
92
|
+
return useMutation({
|
|
93
|
+
mutationFn: async (params) => {
|
|
94
|
+
return await entity.insert({ ...params, returning });
|
|
95
|
+
},
|
|
96
|
+
onSuccess: (data) => {
|
|
97
|
+
if (shouldInvalidate) {
|
|
98
|
+
const key = options?.invalidateKey ?? ["gql"];
|
|
99
|
+
queryClient.invalidateQueries({ queryKey: key });
|
|
100
|
+
}
|
|
101
|
+
options?.onSuccess?.(data);
|
|
102
|
+
},
|
|
103
|
+
onError: options?.onError
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
function useEntityUpdate(entity, returning, options) {
|
|
107
|
+
const queryClient = useQueryClient();
|
|
108
|
+
const shouldInvalidate = options?.invalidate !== false;
|
|
109
|
+
return useMutation({
|
|
110
|
+
mutationFn: async (params) => {
|
|
111
|
+
return await entity.update({ ...params, returning });
|
|
112
|
+
},
|
|
113
|
+
onSuccess: (data) => {
|
|
114
|
+
if (shouldInvalidate) {
|
|
115
|
+
const key = options?.invalidateKey ?? ["gql"];
|
|
116
|
+
queryClient.invalidateQueries({ queryKey: key });
|
|
117
|
+
}
|
|
118
|
+
options?.onSuccess?.(data);
|
|
119
|
+
},
|
|
120
|
+
onError: options?.onError
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
function useEntityDelete(entity, returning, options) {
|
|
124
|
+
const queryClient = useQueryClient();
|
|
125
|
+
const shouldInvalidate = options?.invalidate !== false;
|
|
126
|
+
return useMutation({
|
|
127
|
+
mutationFn: async (params) => {
|
|
128
|
+
return await entity.delete({ ...params, returning });
|
|
129
|
+
},
|
|
130
|
+
onSuccess: (data) => {
|
|
131
|
+
if (shouldInvalidate) {
|
|
132
|
+
const key = options?.invalidateKey ?? ["gql"];
|
|
133
|
+
queryClient.invalidateQueries({ queryKey: key });
|
|
134
|
+
}
|
|
135
|
+
options?.onSuccess?.(data);
|
|
136
|
+
},
|
|
137
|
+
onError: options?.onError
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
// src/useEntityQuery.ts
|
|
141
|
+
import { useQuery as useQuery2 } from "@tanstack/react-query";
|
|
142
|
+
function useEntityQuery(entity, params, options) {
|
|
143
|
+
const queryKey = options?.queryKey ?? [
|
|
144
|
+
"gql",
|
|
145
|
+
"single",
|
|
146
|
+
params.select,
|
|
147
|
+
params.where,
|
|
148
|
+
params.orderBy,
|
|
149
|
+
params.offset
|
|
150
|
+
];
|
|
151
|
+
return useQuery2({
|
|
152
|
+
queryKey,
|
|
153
|
+
queryFn: async () => {
|
|
154
|
+
return await entity.querySingle(params);
|
|
155
|
+
},
|
|
156
|
+
enabled: options?.enabled,
|
|
157
|
+
gcTime: options?.gcTime,
|
|
158
|
+
staleTime: options?.staleTime,
|
|
159
|
+
refetchOnWindowFocus: options?.refetchOnWindowFocus
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
export {
|
|
163
|
+
useGraphQLClient,
|
|
164
|
+
useEntityUpdate,
|
|
165
|
+
useEntityQuery,
|
|
166
|
+
useEntityList,
|
|
167
|
+
useEntityInsert,
|
|
168
|
+
useEntityInfiniteQuery,
|
|
169
|
+
useEntityDelete,
|
|
170
|
+
useEntity,
|
|
171
|
+
GraphQLProvider
|
|
172
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@drizzle-graphql-suite/query",
|
|
3
|
+
"version": "0.5.0",
|
|
4
|
+
"description": "React Query hooks for the Drizzle GraphQL client with caching and automatic invalidation",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "https://github.com/dmythro",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/annexare/drizzle-graphql-suite.git",
|
|
10
|
+
"directory": "packages/query"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://github.com/annexare/drizzle-graphql-suite/tree/main/packages/query#readme",
|
|
13
|
+
"keywords": [
|
|
14
|
+
"drizzle",
|
|
15
|
+
"graphql",
|
|
16
|
+
"react",
|
|
17
|
+
"react-query",
|
|
18
|
+
"tanstack",
|
|
19
|
+
"hooks",
|
|
20
|
+
"typescript"
|
|
21
|
+
],
|
|
22
|
+
"type": "module",
|
|
23
|
+
"publishConfig": {
|
|
24
|
+
"access": "public"
|
|
25
|
+
},
|
|
26
|
+
"main": "./index.js",
|
|
27
|
+
"types": "./index.d.ts",
|
|
28
|
+
"exports": {
|
|
29
|
+
".": {
|
|
30
|
+
"types": "./index.d.ts",
|
|
31
|
+
"import": "./index.js"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"peerDependencies": {
|
|
35
|
+
"@drizzle-graphql-suite/client": ">=0.5.0",
|
|
36
|
+
"@tanstack/react-query": ">=5.0.0",
|
|
37
|
+
"react": ">=18.0.0"
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { AnyEntityDefs, GraphQLClient, SchemaDescriptor } from '@drizzle-graphql-suite/client';
|
|
2
|
+
import { type ReactNode } from 'react';
|
|
3
|
+
export declare function GraphQLProvider<TSchema extends SchemaDescriptor, TDefs extends AnyEntityDefs>({ client, children, }: {
|
|
4
|
+
client: GraphQLClient<TSchema, TDefs>;
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export declare function useGraphQLClient<TSchema extends SchemaDescriptor = SchemaDescriptor, TDefs extends AnyEntityDefs = AnyEntityDefs>(): GraphQLClient<TSchema, TDefs>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import './test-setup';
|
|
2
|
+
import { QueryClient } from '@tanstack/react-query';
|
|
3
|
+
import { type ReactNode } from 'react';
|
|
4
|
+
type RenderHookOptions = {
|
|
5
|
+
wrapper?: (props: {
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
}) => ReactNode;
|
|
8
|
+
};
|
|
9
|
+
type RenderHookResult<T> = {
|
|
10
|
+
result: {
|
|
11
|
+
current: T;
|
|
12
|
+
};
|
|
13
|
+
rerender: () => void;
|
|
14
|
+
unmount: () => void;
|
|
15
|
+
};
|
|
16
|
+
export declare function renderHook<T>(callback: () => T, options?: RenderHookOptions): RenderHookResult<T>;
|
|
17
|
+
export declare function renderHookAsync<T>(callback: () => T, options?: RenderHookOptions): Promise<RenderHookResult<T>>;
|
|
18
|
+
type MockParams = any;
|
|
19
|
+
export declare function createMockEntityClient(): {
|
|
20
|
+
query: import("bun:test").Mock<(p: MockParams) => Promise<Record<string, unknown>[]>>;
|
|
21
|
+
querySingle: import("bun:test").Mock<(p: MockParams) => Promise<Record<string, unknown> | null>>;
|
|
22
|
+
count: import("bun:test").Mock<(p: MockParams) => Promise<number>>;
|
|
23
|
+
insert: import("bun:test").Mock<(p: MockParams) => Promise<Record<string, unknown>[]>>;
|
|
24
|
+
insertSingle: import("bun:test").Mock<(p: MockParams) => Promise<Record<string, unknown> | null>>;
|
|
25
|
+
update: import("bun:test").Mock<(p: MockParams) => Promise<Record<string, unknown>[]>>;
|
|
26
|
+
delete: import("bun:test").Mock<(p: MockParams) => Promise<Record<string, unknown>[]>>;
|
|
27
|
+
};
|
|
28
|
+
export declare function createMockGraphQLClient(entityClient?: any): {
|
|
29
|
+
entity: import("bun:test").Mock<(name: string) => any>;
|
|
30
|
+
url: string;
|
|
31
|
+
schema: {};
|
|
32
|
+
execute: import("bun:test").Mock<() => Promise<{
|
|
33
|
+
data: {};
|
|
34
|
+
}>>;
|
|
35
|
+
};
|
|
36
|
+
export declare function createTestQueryClient(): QueryClient;
|
|
37
|
+
export declare function createWrapper(mockClient: any, queryClient?: QueryClient): ({ children }: {
|
|
38
|
+
children: ReactNode;
|
|
39
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
40
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { AnyEntityDefs, GraphQLClient, SchemaDescriptor } from '@drizzle-graphql-suite/client';
|
|
2
|
+
export type GraphQLClientContext<TSchema extends SchemaDescriptor = SchemaDescriptor, TDefs extends AnyEntityDefs = AnyEntityDefs> = {
|
|
3
|
+
client: GraphQLClient<TSchema, TDefs>;
|
|
4
|
+
};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import type { AnyEntityDefs, EntityClient, EntityDef, SchemaDescriptor } from '@drizzle-graphql-suite/client';
|
|
2
|
+
export declare function useEntity<TSchema extends SchemaDescriptor, TDefs extends AnyEntityDefs, TEntityName extends string & keyof TSchema>(entityName: TEntityName): TEntityName extends keyof TDefs ? EntityClient<TDefs, TDefs[TEntityName] & EntityDef> : EntityClient<TDefs, EntityDef>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { AnyEntityDefs, EntityClient, EntityDef, InferResult } from '@drizzle-graphql-suite/client';
|
|
2
|
+
import { type UseInfiniteQueryResult } from '@tanstack/react-query';
|
|
3
|
+
type EntityInfiniteParams<TEntity extends EntityDef, TSelect extends Record<string, unknown>> = {
|
|
4
|
+
select: TSelect;
|
|
5
|
+
where?: TEntity extends {
|
|
6
|
+
filters: infer F;
|
|
7
|
+
} ? F : never;
|
|
8
|
+
pageSize: number;
|
|
9
|
+
orderBy?: TEntity extends {
|
|
10
|
+
orderBy: infer O;
|
|
11
|
+
} ? O : never;
|
|
12
|
+
};
|
|
13
|
+
type EntityInfiniteOptions = {
|
|
14
|
+
enabled?: boolean;
|
|
15
|
+
gcTime?: number;
|
|
16
|
+
staleTime?: number;
|
|
17
|
+
queryKey?: unknown[];
|
|
18
|
+
};
|
|
19
|
+
type PageData<T> = {
|
|
20
|
+
items: T[];
|
|
21
|
+
count: number;
|
|
22
|
+
};
|
|
23
|
+
export declare function useEntityInfiniteQuery<TDefs extends AnyEntityDefs, TEntity extends EntityDef, TSelect extends Record<string, unknown>>(entity: EntityClient<TDefs, TEntity>, params: EntityInfiniteParams<TEntity, TSelect>, options?: EntityInfiniteOptions): UseInfiniteQueryResult<{
|
|
24
|
+
pages: PageData<InferResult<TDefs, TEntity, TSelect>>[];
|
|
25
|
+
}>;
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { AnyEntityDefs, EntityClient, EntityDef, InferResult } from '@drizzle-graphql-suite/client';
|
|
2
|
+
import { type UseQueryResult } from '@tanstack/react-query';
|
|
3
|
+
type EntityListParams<TEntity extends EntityDef, TSelect extends Record<string, unknown>> = {
|
|
4
|
+
select: TSelect;
|
|
5
|
+
where?: TEntity extends {
|
|
6
|
+
filters: infer F;
|
|
7
|
+
} ? F : never;
|
|
8
|
+
limit?: number;
|
|
9
|
+
offset?: number;
|
|
10
|
+
orderBy?: TEntity extends {
|
|
11
|
+
orderBy: infer O;
|
|
12
|
+
} ? O : never;
|
|
13
|
+
};
|
|
14
|
+
type EntityListOptions = {
|
|
15
|
+
enabled?: boolean;
|
|
16
|
+
gcTime?: number;
|
|
17
|
+
staleTime?: number;
|
|
18
|
+
refetchOnWindowFocus?: boolean;
|
|
19
|
+
queryKey?: unknown[];
|
|
20
|
+
};
|
|
21
|
+
export declare function useEntityList<TDefs extends AnyEntityDefs, TEntity extends EntityDef, TSelect extends Record<string, unknown>>(entity: EntityClient<TDefs, TEntity>, params: EntityListParams<TEntity, TSelect>, options?: EntityListOptions): UseQueryResult<InferResult<TDefs, TEntity, TSelect>[]>;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { AnyEntityDefs, EntityClient, EntityDef, InferResult } from '@drizzle-graphql-suite/client';
|
|
2
|
+
import { type UseMutationResult } from '@tanstack/react-query';
|
|
3
|
+
type InsertOptions<TResult> = {
|
|
4
|
+
invalidate?: boolean;
|
|
5
|
+
invalidateKey?: unknown[];
|
|
6
|
+
onSuccess?: (data: TResult) => void;
|
|
7
|
+
onError?: (error: Error) => void;
|
|
8
|
+
};
|
|
9
|
+
export declare function useEntityInsert<TDefs extends AnyEntityDefs, TEntity extends EntityDef, TSelect extends Record<string, unknown>>(entity: EntityClient<TDefs, TEntity>, returning?: TSelect, options?: InsertOptions<InferResult<TDefs, TEntity, TSelect>[]>): UseMutationResult<InferResult<TDefs, TEntity, TSelect>[], Error, {
|
|
10
|
+
values: TEntity extends {
|
|
11
|
+
insertInput: infer I;
|
|
12
|
+
} ? I[] : never;
|
|
13
|
+
}>;
|
|
14
|
+
type UpdateParams<TEntity extends EntityDef> = {
|
|
15
|
+
set: TEntity extends {
|
|
16
|
+
updateInput: infer U;
|
|
17
|
+
} ? U : never;
|
|
18
|
+
where?: TEntity extends {
|
|
19
|
+
filters: infer F;
|
|
20
|
+
} ? F : never;
|
|
21
|
+
};
|
|
22
|
+
type UpdateOptions<TResult> = {
|
|
23
|
+
invalidate?: boolean;
|
|
24
|
+
invalidateKey?: unknown[];
|
|
25
|
+
onSuccess?: (data: TResult) => void;
|
|
26
|
+
onError?: (error: Error) => void;
|
|
27
|
+
};
|
|
28
|
+
export declare function useEntityUpdate<TDefs extends AnyEntityDefs, TEntity extends EntityDef, TSelect extends Record<string, unknown>>(entity: EntityClient<TDefs, TEntity>, returning?: TSelect, options?: UpdateOptions<InferResult<TDefs, TEntity, TSelect>[]>): UseMutationResult<InferResult<TDefs, TEntity, TSelect>[], Error, UpdateParams<TEntity>>;
|
|
29
|
+
type DeleteParams<TEntity extends EntityDef> = {
|
|
30
|
+
where?: TEntity extends {
|
|
31
|
+
filters: infer F;
|
|
32
|
+
} ? F : never;
|
|
33
|
+
};
|
|
34
|
+
type DeleteOptions<TResult> = {
|
|
35
|
+
invalidate?: boolean;
|
|
36
|
+
invalidateKey?: unknown[];
|
|
37
|
+
onSuccess?: (data: TResult) => void;
|
|
38
|
+
onError?: (error: Error) => void;
|
|
39
|
+
};
|
|
40
|
+
export declare function useEntityDelete<TDefs extends AnyEntityDefs, TEntity extends EntityDef, TSelect extends Record<string, unknown>>(entity: EntityClient<TDefs, TEntity>, returning?: TSelect, options?: DeleteOptions<InferResult<TDefs, TEntity, TSelect>[]>): UseMutationResult<InferResult<TDefs, TEntity, TSelect>[], Error, DeleteParams<TEntity>>;
|
|
41
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { AnyEntityDefs, EntityClient, EntityDef, InferResult } from '@drizzle-graphql-suite/client';
|
|
2
|
+
import { type UseQueryResult } from '@tanstack/react-query';
|
|
3
|
+
type EntityQueryParams<TEntity extends EntityDef, TSelect extends Record<string, unknown>> = {
|
|
4
|
+
select: TSelect;
|
|
5
|
+
where?: TEntity extends {
|
|
6
|
+
filters: infer F;
|
|
7
|
+
} ? F : never;
|
|
8
|
+
offset?: number;
|
|
9
|
+
orderBy?: TEntity extends {
|
|
10
|
+
orderBy: infer O;
|
|
11
|
+
} ? O : never;
|
|
12
|
+
};
|
|
13
|
+
type EntityQueryOptions = {
|
|
14
|
+
enabled?: boolean;
|
|
15
|
+
gcTime?: number;
|
|
16
|
+
staleTime?: number;
|
|
17
|
+
refetchOnWindowFocus?: boolean;
|
|
18
|
+
queryKey?: unknown[];
|
|
19
|
+
};
|
|
20
|
+
export declare function useEntityQuery<TDefs extends AnyEntityDefs, TEntity extends EntityDef, TSelect extends Record<string, unknown>>(entity: EntityClient<TDefs, TEntity>, params: EntityQueryParams<TEntity, TSelect>, options?: EntityQueryOptions): UseQueryResult<InferResult<TDefs, TEntity, TSelect> | null>;
|
|
21
|
+
export {};
|