-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathindex.ts
More file actions
61 lines (61 loc) · 2.08 KB
/
index.ts
File metadata and controls
61 lines (61 loc) · 2.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/**
* ORM Client - createClient factory
* @generated by @constructive-io/graphql-codegen
* DO NOT EDIT - changes will be overwritten
*/
import { OrmClient } from './client';
import type { OrmClientConfig } from './client';
import { EmailModel } from './models/email';
import { PhoneNumberModel } from './models/phoneNumber';
import { CryptoAddressModel } from './models/cryptoAddress';
import { ConnectedAccountModel } from './models/connectedAccount';
import { AuditLogModel } from './models/auditLog';
import { RoleTypeModel } from './models/roleType';
import { UserModel } from './models/user';
import { createQueryOperations } from './query';
import { createMutationOperations } from './mutation';
export type { OrmClientConfig, QueryResult, GraphQLError, GraphQLAdapter } from './client';
export { GraphQLRequestError } from './client';
export { QueryBuilder } from './query-builder';
export * from './select-types';
export * from './models';
export { NodeHttpAdapter } from './node-fetch';
export { createQueryOperations } from './query';
export { createMutationOperations } from './mutation';
/**
* Create an ORM client instance
*
* @example
* ```typescript
* const db = createClient({
* endpoint: 'https://api.example.com/graphql',
* headers: { Authorization: 'Bearer token' },
* });
*
* // Query users
* const users = await db.user.findMany({
* select: { id: true, name: true },
* first: 10,
* }).execute();
*
* // Create a user
* const newUser = await db.user.create({
* data: { name: 'John', email: 'john@example.com' },
* select: { id: true },
* }).execute();
* ```
*/
export function createClient(config: OrmClientConfig) {
const client = new OrmClient(config);
return {
email: new EmailModel(client),
phoneNumber: new PhoneNumberModel(client),
cryptoAddress: new CryptoAddressModel(client),
connectedAccount: new ConnectedAccountModel(client),
auditLog: new AuditLogModel(client),
roleType: new RoleTypeModel(client),
user: new UserModel(client),
query: createQueryOperations(client),
mutation: createMutationOperations(client),
};
}