@drizzle-graphql-suite/client 0.8.1 → 0.8.3
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/client.d.ts +5 -5
- package/entity.d.ts +22 -20
- package/index.d.ts +2 -2
- package/index.js +11 -11
- package/infer.d.ts +12 -7
- package/package.json +2 -1
- package/schema-builder.d.ts +2 -14
- package/types.d.ts +4 -0
package/client.d.ts
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
+
import type { BuildSchemaConfig } from '@drizzle-graphql-suite/schema';
|
|
1
2
|
import { type EntityClient } from './entity';
|
|
2
3
|
import type { InferEntityDefs } from './infer';
|
|
3
|
-
import {
|
|
4
|
-
import type { AnyEntityDefs, ClientConfig, SchemaDescriptor } from './types';
|
|
4
|
+
import type { AnyEntityDefs, ClientConfig, EntityDefsRef, SchemaDescriptor } from './types';
|
|
5
5
|
export declare class GraphQLClient<TSchema extends SchemaDescriptor, TDefs extends AnyEntityDefs = AnyEntityDefs> {
|
|
6
6
|
private url;
|
|
7
7
|
private schema;
|
|
8
8
|
private headers?;
|
|
9
9
|
constructor(config: ClientConfig<TSchema>);
|
|
10
|
-
entity<TEntityName extends string & keyof TSchema & keyof TDefs>(entityName: TEntityName): EntityClient<TDefs
|
|
10
|
+
entity<TEntityName extends string & keyof TSchema & keyof TDefs>(entityName: TEntityName): EntityClient<EntityDefsRef<TDefs>, TEntityName>;
|
|
11
11
|
execute(query: string, variables?: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
12
12
|
}
|
|
13
|
-
export type DrizzleClientConfig<TSchema extends Record<string, unknown>, TConfig extends
|
|
13
|
+
export type DrizzleClientConfig<TSchema extends Record<string, unknown>, TConfig extends BuildSchemaConfig> = {
|
|
14
14
|
schema: TSchema;
|
|
15
15
|
config: TConfig;
|
|
16
16
|
url: string | (() => string);
|
|
17
17
|
headers?: HeadersInit | (() => HeadersInit | Promise<HeadersInit>);
|
|
18
18
|
};
|
|
19
|
-
export declare function createDrizzleClient<TSchema extends Record<string, unknown>, const TConfig extends
|
|
19
|
+
export declare function createDrizzleClient<TSchema extends Record<string, unknown>, const TConfig extends BuildSchemaConfig>(options: DrizzleClientConfig<TSchema, TConfig>): GraphQLClient<SchemaDescriptor, InferEntityDefs<TSchema, TConfig>>;
|
package/entity.d.ts
CHANGED
|
@@ -1,57 +1,59 @@
|
|
|
1
|
-
import type { AnyEntityDefs, EntityDef, EntityDescriptor, InferResult, SchemaDescriptor } from './types';
|
|
2
|
-
|
|
1
|
+
import type { AnyEntityDefs, EntityDef, EntityDefsRef, EntityDescriptor, InferResult, SchemaDescriptor } from './types';
|
|
2
|
+
type ResolveEntity<TRef extends EntityDefsRef<AnyEntityDefs>, TEntityName extends string> = TRef['__defs'][TEntityName] & EntityDef;
|
|
3
|
+
export interface EntityClient<TRef extends EntityDefsRef<AnyEntityDefs>, TEntityName extends string> {
|
|
3
4
|
query<S extends Record<string, unknown>>(params: {
|
|
4
5
|
select: S;
|
|
5
|
-
where?:
|
|
6
|
+
where?: ResolveEntity<TRef, TEntityName> extends {
|
|
6
7
|
filters: infer F;
|
|
7
8
|
} ? F : never;
|
|
8
9
|
limit?: number;
|
|
9
10
|
offset?: number;
|
|
10
|
-
orderBy?:
|
|
11
|
+
orderBy?: ResolveEntity<TRef, TEntityName> extends {
|
|
11
12
|
orderBy: infer O;
|
|
12
13
|
} ? O : never;
|
|
13
|
-
}): Promise<InferResult<
|
|
14
|
+
}): Promise<InferResult<TRef['__defs'], ResolveEntity<TRef, TEntityName>, S>[]>;
|
|
14
15
|
querySingle<S extends Record<string, unknown>>(params: {
|
|
15
16
|
select: S;
|
|
16
|
-
where?:
|
|
17
|
+
where?: ResolveEntity<TRef, TEntityName> extends {
|
|
17
18
|
filters: infer F;
|
|
18
19
|
} ? F : never;
|
|
19
20
|
offset?: number;
|
|
20
|
-
orderBy?:
|
|
21
|
+
orderBy?: ResolveEntity<TRef, TEntityName> extends {
|
|
21
22
|
orderBy: infer O;
|
|
22
23
|
} ? O : never;
|
|
23
|
-
}): Promise<InferResult<
|
|
24
|
+
}): Promise<InferResult<TRef['__defs'], ResolveEntity<TRef, TEntityName>, S> | null>;
|
|
24
25
|
count(params?: {
|
|
25
|
-
where?:
|
|
26
|
+
where?: ResolveEntity<TRef, TEntityName> extends {
|
|
26
27
|
filters: infer F;
|
|
27
28
|
} ? F : never;
|
|
28
29
|
}): Promise<number>;
|
|
29
30
|
insert<S extends Record<string, unknown>>(params: {
|
|
30
|
-
values:
|
|
31
|
+
values: ResolveEntity<TRef, TEntityName> extends {
|
|
31
32
|
insertInput: infer I;
|
|
32
33
|
} ? I[] : never;
|
|
33
34
|
returning?: S;
|
|
34
|
-
}): Promise<InferResult<
|
|
35
|
+
}): Promise<InferResult<TRef['__defs'], ResolveEntity<TRef, TEntityName>, S>[]>;
|
|
35
36
|
insertSingle<S extends Record<string, unknown>>(params: {
|
|
36
|
-
values:
|
|
37
|
+
values: ResolveEntity<TRef, TEntityName> extends {
|
|
37
38
|
insertInput: infer I;
|
|
38
39
|
} ? I : never;
|
|
39
40
|
returning?: S;
|
|
40
|
-
}): Promise<InferResult<
|
|
41
|
+
}): Promise<InferResult<TRef['__defs'], ResolveEntity<TRef, TEntityName>, S> | null>;
|
|
41
42
|
update<S extends Record<string, unknown>>(params: {
|
|
42
|
-
set:
|
|
43
|
+
set: ResolveEntity<TRef, TEntityName> extends {
|
|
43
44
|
updateInput: infer U;
|
|
44
45
|
} ? U : never;
|
|
45
|
-
where?:
|
|
46
|
+
where?: ResolveEntity<TRef, TEntityName> extends {
|
|
46
47
|
filters: infer F;
|
|
47
48
|
} ? F : never;
|
|
48
49
|
returning?: S;
|
|
49
|
-
}): Promise<InferResult<
|
|
50
|
+
}): Promise<InferResult<TRef['__defs'], ResolveEntity<TRef, TEntityName>, S>[]>;
|
|
50
51
|
delete<S extends Record<string, unknown>>(params: {
|
|
51
|
-
where?:
|
|
52
|
+
where?: ResolveEntity<TRef, TEntityName> extends {
|
|
52
53
|
filters: infer F;
|
|
53
54
|
} ? F : never;
|
|
54
55
|
returning?: S;
|
|
55
|
-
}): Promise<InferResult<
|
|
56
|
-
}
|
|
57
|
-
export declare function createEntityClient<
|
|
56
|
+
}): Promise<InferResult<TRef['__defs'], ResolveEntity<TRef, TEntityName>, S>[]>;
|
|
57
|
+
}
|
|
58
|
+
export declare function createEntityClient<TRef extends EntityDefsRef<AnyEntityDefs>, TEntityName extends string>(entityName: string, entityDef: EntityDescriptor, schema: SchemaDescriptor, executeGraphQL: (query: string, variables: Record<string, unknown>) => Promise<Record<string, unknown>>): EntityClient<TRef, TEntityName>;
|
|
59
|
+
export {};
|
package/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { GraphQLClient } from './client';
|
|
2
2
|
import type { AnyEntityDefs, ClientConfig, SchemaDescriptor } from './types';
|
|
3
3
|
export declare function createClient<TSchema extends SchemaDescriptor, TDefs extends AnyEntityDefs = AnyEntityDefs>(config: ClientConfig<TSchema>): GraphQLClient<TSchema, TDefs>;
|
|
4
|
+
export type { BuildSchemaConfig } from '@drizzle-graphql-suite/schema';
|
|
4
5
|
export type { DrizzleClientConfig } from './client';
|
|
5
6
|
export { createDrizzleClient, GraphQLClient } from './client';
|
|
6
7
|
export type { EntityClient } from './entity';
|
|
7
8
|
export { GraphQLClientError, NetworkError } from './errors';
|
|
8
9
|
export type { InferEntityDefs } from './infer';
|
|
9
|
-
export type { ClientSchemaConfig } from './schema-builder';
|
|
10
10
|
export { buildSchemaDescriptor } from './schema-builder';
|
|
11
|
-
export type { AnyEntityDefs, ClientConfig, EntityDef, EntityDescriptor, InferResult, SchemaDescriptor, SelectInput, } from './types';
|
|
11
|
+
export type { AnyEntityDefs, ClientConfig, EntityDef, EntityDefsRef, EntityDescriptor, InferResult, SchemaDescriptor, SelectInput, } from './types';
|
package/index.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
var j=(E)=>E.charAt(0).toUpperCase()+E.slice(1);function G(E,x,$,Y=4){let
|
|
2
|
-
`)}function L(E){return`${j(E)}Filters`}function S(E){return`${j(E)}OrderBy`}function p(E){return`${j(E)}InsertInput`}function c(E){return`${j(E)}UpdateInput`}function T(E,x,$,Y,
|
|
1
|
+
var j=(E)=>E.charAt(0).toUpperCase()+E.slice(1);function G(E,x,$,Y=4){let H=" ".repeat(Y),C=[];for(let[R,J]of Object.entries(E)){if(J===!0){C.push(`${H}${R}`);continue}if(typeof J==="object"&&J!==null){let X=$.relations[R];if(!X)continue;let A=x[X.entity];if(!A)continue;let Z=G(J,x,A,Y+2);C.push(`${H}${R} {`),C.push(Z),C.push(`${H}}`)}}return C.join(`
|
|
2
|
+
`)}function L(E){return`${j(E)}Filters`}function S(E){return`${j(E)}OrderBy`}function p(E){return`${j(E)}InsertInput`}function c(E){return`${j(E)}UpdateInput`}function T(E,x,$,Y,H,C,R,J){let X=x.queryListName;if(!X)throw Error(`Entity '${E}' has no list query`);let A=L(E),Z=S(E),_=`${j(X)}Query`,V=[],I=[];if(H)V.push(`$where: ${A}`),I.push("where: $where");if(C)V.push(`$orderBy: ${Z}`),I.push("orderBy: $orderBy");if(R)V.push("$limit: Int"),I.push("limit: $limit");if(J)V.push("$offset: Int"),I.push("offset: $offset");let q=V.length?`(${V.join(", ")})`:"",U=I.length?`(${I.join(", ")})`:"",F=G(Y,$,x);return{query:`query ${_}${q} {
|
|
3
3
|
${X}${U} {
|
|
4
4
|
${F}
|
|
5
5
|
}
|
|
6
|
-
}`,variables:{},operationName:_}}function d(E,x,$,Y,
|
|
7
|
-
${
|
|
6
|
+
}`,variables:{},operationName:_}}function d(E,x,$,Y,H,C,R){let J=x.queryName;if(!J)throw Error(`Entity '${E}' has no single query`);let X=L(E),A=S(E),Z=`${j(J)}SingleQuery`,_=[],V=[];if(H)_.push(`$where: ${X}`),V.push("where: $where");if(C)_.push(`$orderBy: ${A}`),V.push("orderBy: $orderBy");if(R)_.push("$offset: Int"),V.push("offset: $offset");let I=_.length?`(${_.join(", ")})`:"",q=V.length?`(${V.join(", ")})`:"",U=G(Y,$,x);return{query:`query ${Z}${I} {
|
|
7
|
+
${J}${q} {
|
|
8
8
|
${U}
|
|
9
9
|
}
|
|
10
|
-
}`,variables:{},operationName:Z}}function b(E,x,$){let Y=x.countName;if(!Y)throw Error(`Entity '${E}' has no count query`);let
|
|
10
|
+
}`,variables:{},operationName:Z}}function b(E,x,$){let Y=x.countName;if(!Y)throw Error(`Entity '${E}' has no count query`);let H=L(E),C=`${j(Y)}Query`,R=[],J=[];if($)R.push(`$where: ${H}`),J.push("where: $where");let X=R.length?`(${R.join(", ")})`:"",A=J.length?`(${J.join(", ")})`:"";return{query:`query ${C}${X} {
|
|
11
11
|
${Y}${A}
|
|
12
|
-
}`,variables:{},operationName:C}}function
|
|
12
|
+
}`,variables:{},operationName:C}}function Q(E,x,$,Y,H){let C=H?x.insertSingleName:x.insertName;if(!C)throw Error(`Entity '${E}' has no ${H?"insertSingle":"insert"} mutation`);let R=p(E),J=`${j(C)}Mutation`,A=`($values: ${H?`${R}!`:`[${R}!]!`})`,Z="(values: $values)",_="";if(Y)_=` {
|
|
13
13
|
${G(Y,$,x)}
|
|
14
|
-
}`;return{query:`mutation ${
|
|
14
|
+
}`;return{query:`mutation ${J}${A} {
|
|
15
15
|
${C}${Z}${_}
|
|
16
|
-
}`,variables:{},operationName:
|
|
16
|
+
}`,variables:{},operationName:J}}function v(E,x,$,Y,H){let C=x.updateName;if(!C)throw Error(`Entity '${E}' has no update mutation`);let R=c(E),J=L(E),X=`${j(C)}Mutation`,A=[`$set: ${R}!`],Z=["set: $set"];if(H)A.push(`$where: ${J}`),Z.push("where: $where");let _=`(${A.join(", ")})`,V=`(${Z.join(", ")})`,I="";if(Y)I=` {
|
|
17
17
|
${G(Y,$,x)}
|
|
18
18
|
}`;return{query:`mutation ${X}${_} {
|
|
19
19
|
${C}${V}${I}
|
|
20
|
-
}`,variables:{},operationName:X}}function g(E,x,$,Y,
|
|
20
|
+
}`,variables:{},operationName:X}}function g(E,x,$,Y,H){let C=x.deleteName;if(!C)throw Error(`Entity '${E}' has no delete mutation`);let R=L(E),J=`${j(C)}Mutation`,X=[],A=[];if(H)X.push(`$where: ${R}`),A.push("where: $where");let Z=X.length?`(${X.join(", ")})`:"",_=A.length?`(${A.join(", ")})`:"",V="";if(Y)V=` {
|
|
21
21
|
${G(Y,$,x)}
|
|
22
|
-
}`;return{query:`mutation ${
|
|
22
|
+
}`;return{query:`mutation ${J}${Z} {
|
|
23
23
|
${C}${_}${V}
|
|
24
|
-
}`,variables:{},operationName:
|
|
24
|
+
}`,variables:{},operationName:J}}function D(E,x,$,Y){return{async query(H){let{select:C,where:R,limit:J,offset:X,orderBy:A}=H,Z=T(E,x,$,C,R!=null,A!=null,J!=null,X!=null),_={};if(R!=null)_.where=R;if(A!=null)_.orderBy=A;if(J!=null)_.limit=J;if(X!=null)_.offset=X;return(await Y(Z.query,_))[x.queryListName]},async querySingle(H){let{select:C,where:R,offset:J,orderBy:X}=H,A=d(E,x,$,C,R!=null,X!=null,J!=null),Z={};if(R!=null)Z.where=R;if(X!=null)Z.orderBy=X;if(J!=null)Z.offset=J;return(await Y(A.query,Z))[x.queryName]??null},async count(H){let C=H?.where,R=b(E,x,C!=null),J={};if(C!=null)J.where=C;return(await Y(R.query,J))[x.countName]},async insert(H){let{values:C,returning:R}=H,J=Q(E,x,$,R,!1),X={values:C};return(await Y(J.query,X))[x.insertName]},async insertSingle(H){let{values:C,returning:R}=H,J=Q(E,x,$,R,!0),X={values:C};return(await Y(J.query,X))[x.insertSingleName]??null},async update(H){let{set:C,where:R,returning:J}=H,X=v(E,x,$,J,R!=null),A={set:C};if(R!=null)A.where=R;return(await Y(X.query,A))[x.updateName]},async delete(H){let{where:C,returning:R}=H,J=g(E,x,$,R,C!=null),X={};if(C!=null)X.where=C;return(await Y(J.query,X))[x.deleteName]}}}class K extends Error{errors;status;constructor(E,x=200){let $=E.map((Y)=>Y.message).join("; ");super($);this.name="GraphQLClientError",this.errors=E,this.status=x}}class W extends Error{status;constructor(E,x){super(E);this.name="NetworkError",this.status=x}}import{getTableColumns as f,getTableName as h,is as w,Many as N,One as u,Relations as m,Table as l}from"drizzle-orm";var z=(E)=>E.charAt(0).toUpperCase()+E.slice(1);function k(E,x={}){let $=new Set(x.tables?.exclude??[]),Y=x.suffixes?.list??"s",H=new Map,C=new Map;for(let[A,Z]of Object.entries(E))if(w(Z,l)){if($.has(A))continue;let _=h(Z),V=Object.keys(f(Z));H.set(A,{table:Z,dbName:_,columns:V}),C.set(_,A)}let R=new Map;for(let A of Object.values(E)){if(!w(A,m))continue;let Z=h(A.table),_=C.get(Z);if(!_||!H.has(_))continue;let V={one:(U,F)=>{return new u(A.table,U,F,!1)},many:(U,F)=>{return new N(A.table,U,F)}},I=A.config(V),q={};for(let[U,F]of Object.entries(I)){let O=F,P=O.referencedTableName;if(!P)continue;let B=C.get(P);if(!B)continue;let o=w(O,u)?"one":"many";q[U]={entity:B,type:o}}R.set(_,q)}let J=x.pruneRelations??{};for(let[A,Z]of R)for(let _ of Object.keys(Z)){let V=`${A}.${_}`;if(J[V]===!1)delete Z[_]}let X={};for(let[A,{columns:Z}]of H){let _=R.get(A)??{};X[A]={queryName:A,queryListName:`${A}${Y}`,countName:`${A}Count`,insertName:`insertInto${z(A)}`,insertSingleName:`insertInto${z(A)}Single`,updateName:`update${z(A)}`,deleteName:`deleteFrom${z(A)}`,fields:Z,relations:_}}return X}class M{url;schema;headers;constructor(E){this.url=E.url,this.schema=E.schema,this.headers=E.headers}entity(E){let x=this.schema[E];if(!x)throw Error(`Entity '${E}' not found in schema`);return D(E,x,this.schema,($,Y)=>this.execute($,Y))}async execute(E,x={}){let $=typeof this.url==="function"?this.url():this.url,Y={"Content-Type":"application/json",...typeof this.headers==="function"?await this.headers():this.headers??{}},H;try{H=await fetch($,{method:"POST",headers:Y,body:JSON.stringify({query:E,variables:x})})}catch(R){throw new W(R instanceof Error?R.message:"Network request failed",0)}if(!H.ok)throw new W(`HTTP ${H.status}: ${H.statusText}`,H.status);let C=await H.json();if(C.errors?.length)throw new K(C.errors,H.status);if(!C.data)throw new K([{message:"No data in response"}],H.status);return C.data}}function y(E){let x=k(E.schema,E.config);return new M({url:E.url,schema:x,headers:E.headers})}function RE(E){return new M(E)}export{y as createDrizzleClient,RE as createClient,k as buildSchemaDescriptor,W as NetworkError,K as GraphQLClientError,M as GraphQLClient};
|
package/infer.d.ts
CHANGED
|
@@ -47,14 +47,15 @@ type ManyRelationFilter<TFilter> = {
|
|
|
47
47
|
type IsResolvableRelation<TSchema, TRel> = TRel extends {
|
|
48
48
|
entity: infer E;
|
|
49
49
|
} ? E extends string ? KeyForDbName<TSchema, E> extends keyof ExtractTables<TSchema> ? true : false : false : false;
|
|
50
|
-
type
|
|
50
|
+
type Prev<T extends unknown[]> = T extends [unknown, ...infer Rest] ? Rest : [];
|
|
51
|
+
type InferRelationFilterFields<TSchema, TRels, TDepth extends unknown[]> = {
|
|
51
52
|
[K in keyof TRels as IsResolvableRelation<TSchema, TRels[K]> extends true ? K : never]?: TRels[K] extends {
|
|
52
53
|
entity: infer E;
|
|
53
54
|
type: infer TRelType;
|
|
54
|
-
} ? E extends string ? KeyForDbName<TSchema, E> extends infer RK ? RK extends keyof ExtractTables<TSchema> ? ExtractTables<TSchema>[RK] extends infer TTarget ? TTarget extends Table ? TRelType extends 'many' ? ManyRelationFilter<InferEntityFilters<TSchema, TTarget
|
|
55
|
+
} ? E extends string ? KeyForDbName<TSchema, E> extends infer RK ? RK extends keyof ExtractTables<TSchema> ? ExtractTables<TSchema>[RK] extends infer TTarget ? TTarget extends Table ? TRelType extends 'many' ? ManyRelationFilter<InferEntityFilters<TSchema, TTarget, Prev<TDepth>>> : InferEntityFilters<TSchema, TTarget, Prev<TDepth>> : never : never : never : never : never : never;
|
|
55
56
|
};
|
|
56
|
-
type InferEntityFilters<TSchema, T extends Table> = ScalarColumnFilters<WireFormat<T['$inferSelect']>> & InferRelationFilterFields<TSchema, InferRelationDefs<TSchema, TableDbName<T
|
|
57
|
-
OR?: InferEntityFilters<TSchema, T>[];
|
|
57
|
+
type InferEntityFilters<TSchema, T extends Table, TDepth extends unknown[] = [0]> = ScalarColumnFilters<WireFormat<T['$inferSelect']>> & (TDepth extends [] ? {} : InferRelationFilterFields<TSchema, InferRelationDefs<TSchema, TableDbName<T>>, TDepth>) & {
|
|
58
|
+
OR?: InferEntityFilters<TSchema, T, TDepth>[];
|
|
58
59
|
};
|
|
59
60
|
type InferInsertInput<T> = T extends Table ? WireFormat<T['$inferInsert']> : never;
|
|
60
61
|
type InferUpdateInput<T> = T extends Table ? {
|
|
@@ -71,6 +72,10 @@ type ExcludedNames<TConfig> = TConfig extends {
|
|
|
71
72
|
exclude: readonly (infer T)[];
|
|
72
73
|
};
|
|
73
74
|
} ? T : never;
|
|
75
|
+
type NumberToTuple<N extends number, T extends unknown[] = []> = T['length'] extends N ? T : T['length'] extends 5 ? T : NumberToTuple<N, [...T, 0]>;
|
|
76
|
+
type ExtractFilterDepth<TConfig> = TConfig extends {
|
|
77
|
+
limitRelationDepth: infer D;
|
|
78
|
+
} ? D extends number ? number extends D ? [0] : NumberToTuple<D> : [0] : [0];
|
|
74
79
|
type TableDbName<T> = T extends Table<infer TConfig> ? TConfig['name'] extends string ? TConfig['name'] : string : string;
|
|
75
80
|
type DbNameToKey<TSchema> = {
|
|
76
81
|
[K in keyof ExtractTables<TSchema>]: TableDbName<ExtractTables<TSchema>[K]>;
|
|
@@ -88,15 +93,15 @@ type ResolveRelationDefs<TSchema, TRels> = {
|
|
|
88
93
|
type: T;
|
|
89
94
|
} : TRels[K] : TRels[K];
|
|
90
95
|
};
|
|
91
|
-
type BuildEntityDef<TSchema, T> = T extends Table ? {
|
|
96
|
+
type BuildEntityDef<TSchema, T, TDepth extends unknown[]> = T extends Table ? {
|
|
92
97
|
fields: WireFormat<T['$inferSelect']>;
|
|
93
98
|
relations: ResolveRelationDefs<TSchema, InferRelationDefs<TSchema, TableDbName<T>>>;
|
|
94
|
-
filters: InferEntityFilters<TSchema, T>;
|
|
99
|
+
filters: InferEntityFilters<TSchema, T, TDepth>;
|
|
95
100
|
insertInput: InferInsertInput<T>;
|
|
96
101
|
updateInput: InferUpdateInput<T>;
|
|
97
102
|
orderBy: InferOrderBy<T>;
|
|
98
103
|
} : never;
|
|
99
104
|
export type InferEntityDefs<TSchema, TConfig = Record<string, never>> = {
|
|
100
|
-
[K in keyof ExtractTables<TSchema> as K extends ExcludedNames<TConfig> ? never : K extends string ? K : never]: BuildEntityDef<TSchema, ExtractTables<TSchema>[K]
|
|
105
|
+
[K in keyof ExtractTables<TSchema> as K extends ExcludedNames<TConfig> ? never : K extends string ? K : never]: BuildEntityDef<TSchema, ExtractTables<TSchema>[K], ExtractFilterDepth<TConfig>>;
|
|
101
106
|
};
|
|
102
107
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@drizzle-graphql-suite/client",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.3",
|
|
4
4
|
"description": "Type-safe GraphQL client with entity-based API and full Drizzle type inference",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "https://github.com/dmythro",
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
}
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
|
+
"@drizzle-graphql-suite/schema": ">=0.8.0",
|
|
35
36
|
"drizzle-orm": ">=0.44.0"
|
|
36
37
|
}
|
|
37
38
|
}
|
package/schema-builder.d.ts
CHANGED
|
@@ -1,15 +1,3 @@
|
|
|
1
|
+
import type { BuildSchemaConfig } from '@drizzle-graphql-suite/schema';
|
|
1
2
|
import type { SchemaDescriptor } from './types';
|
|
2
|
-
export
|
|
3
|
-
mutations?: boolean;
|
|
4
|
-
suffixes?: {
|
|
5
|
-
list?: string;
|
|
6
|
-
single?: string;
|
|
7
|
-
};
|
|
8
|
-
tables?: {
|
|
9
|
-
exclude?: readonly string[];
|
|
10
|
-
};
|
|
11
|
-
pruneRelations?: Record<string, false | 'leaf' | {
|
|
12
|
-
only: string[];
|
|
13
|
-
}>;
|
|
14
|
-
};
|
|
15
|
-
export declare function buildSchemaDescriptor(schema: Record<string, unknown>, config?: ClientSchemaConfig): SchemaDescriptor;
|
|
3
|
+
export declare function buildSchemaDescriptor(schema: Record<string, unknown>, config?: BuildSchemaConfig): SchemaDescriptor;
|
package/types.d.ts
CHANGED
|
@@ -12,6 +12,10 @@ export type EntityDef = {
|
|
|
12
12
|
orderBy?: Record<string, unknown>;
|
|
13
13
|
};
|
|
14
14
|
export type AnyEntityDefs = Record<string, EntityDef>;
|
|
15
|
+
/** Opaque wrapper that prevents TS from expanding entity defs during serialization */
|
|
16
|
+
export interface EntityDefsRef<TDefs extends AnyEntityDefs> {
|
|
17
|
+
readonly __defs: TDefs;
|
|
18
|
+
}
|
|
15
19
|
export type EntityDescriptor = {
|
|
16
20
|
queryName: string;
|
|
17
21
|
queryListName: string;
|