@vrplatform/graphql 1.0.0-staging.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/build/main/client/headers.d.ts +3 -0
- package/build/main/client/headers.js +42 -0
- package/build/main/client/index.d.ts +13 -0
- package/build/main/client/index.js +103 -0
- package/build/main/client/subscription.d.ts +3 -0
- package/build/main/client/subscription.js +29 -0
- package/build/main/common/account.d.ts +2 -0
- package/build/main/common/account.js +7 -0
- package/build/main/common/address.d.ts +9 -0
- package/build/main/common/address.js +2 -0
- package/build/main/common/bank-record.d.ts +2 -0
- package/build/main/common/bank-record.js +7 -0
- package/build/main/common/index.d.ts +5 -0
- package/build/main/common/index.js +21 -0
- package/build/main/common/listings.d.ts +4 -0
- package/build/main/common/listings.js +99 -0
- package/build/main/common/tenant.d.ts +19 -0
- package/build/main/common/tenant.js +85 -0
- package/build/main/constants.d.ts +2 -0
- package/build/main/constants.js +5 -0
- package/build/main/error.d.ts +2 -0
- package/build/main/error.js +6 -0
- package/build/main/gqty/index.d.ts +8 -0
- package/build/main/gqty/index.js +65 -0
- package/build/main/gqty/schema.generated.d.ts +109775 -0
- package/build/main/gqty/schema.generated.js +43373 -0
- package/build/main/index.d.ts +5 -0
- package/build/main/index.js +25 -0
- package/build/main/tsconfig.main.tsbuildinfo +1 -0
- package/build/main/types.d.ts +15 -0
- package/build/main/types.js +2 -0
- package/build/main/wrap.d.ts +12 -0
- package/build/main/wrap.js +47 -0
- package/build/module/client/headers.d.ts +3 -0
- package/build/module/client/headers.js +39 -0
- package/build/module/client/index.d.ts +13 -0
- package/build/module/client/index.js +98 -0
- package/build/module/client/subscription.d.ts +3 -0
- package/build/module/client/subscription.js +26 -0
- package/build/module/common/account.d.ts +2 -0
- package/build/module/common/account.js +4 -0
- package/build/module/common/address.d.ts +9 -0
- package/build/module/common/address.js +1 -0
- package/build/module/common/bank-record.d.ts +2 -0
- package/build/module/common/bank-record.js +4 -0
- package/build/module/common/index.d.ts +5 -0
- package/build/module/common/index.js +5 -0
- package/build/module/common/listings.d.ts +4 -0
- package/build/module/common/listings.js +93 -0
- package/build/module/common/tenant.d.ts +19 -0
- package/build/module/common/tenant.js +77 -0
- package/build/module/constants.d.ts +2 -0
- package/build/module/constants.js +2 -0
- package/build/module/error.d.ts +2 -0
- package/build/module/error.js +2 -0
- package/build/module/gqty/index.d.ts +8 -0
- package/build/module/gqty/index.js +42 -0
- package/build/module/gqty/schema.generated.d.ts +109775 -0
- package/build/module/gqty/schema.generated.js +43370 -0
- package/build/module/index.d.ts +5 -0
- package/build/module/index.js +5 -0
- package/build/module/tsconfig.esm.tsbuildinfo +1 -0
- package/build/module/types.d.ts +15 -0
- package/build/module/types.js +1 -0
- package/build/module/wrap.d.ts +12 -0
- package/build/module/wrap.js +44 -0
- package/package.json +57 -0
- package/src/client/headers.ts +51 -0
- package/src/client/index.ts +152 -0
- package/src/client/subscription.ts +34 -0
- package/src/common/account.ts +6 -0
- package/src/common/address.ts +9 -0
- package/src/common/bank-record.ts +6 -0
- package/src/common/index.ts +5 -0
- package/src/common/listings.ts +106 -0
- package/src/common/tenant.ts +101 -0
- package/src/constants.ts +2 -0
- package/src/error.ts +1 -0
- package/src/gqty/index.ts +63 -0
- package/src/gqty/schema.generated.d.ts +109775 -0
- package/src/gqty/schema.generated.js +43458 -0
- package/src/index.ts +10 -0
- package/src/types.ts +14 -0
- package/src/wrap.ts +67 -0
package/src/index.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export {
|
|
2
|
+
GQtyClient,
|
|
3
|
+
GQtyError,
|
|
4
|
+
ResolveOptions,
|
|
5
|
+
SubscriptionsClient,
|
|
6
|
+
} from 'gqty';
|
|
7
|
+
export { type HasuraClient, useHasuraClient } from './client';
|
|
8
|
+
export * from './common';
|
|
9
|
+
export * from './gqty';
|
|
10
|
+
export { type ResolveOptionsWithSession, wrapGraphQLClient } from './wrap';
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type Headers = { [s: string]: string };
|
|
2
|
+
export type AllowedHeaders =
|
|
3
|
+
| { [s: string]: string }
|
|
4
|
+
| (() => Headers)
|
|
5
|
+
| (() => Promise<Headers>);
|
|
6
|
+
export type GqlAuthParam = {
|
|
7
|
+
accessToken?: string;
|
|
8
|
+
secret?: string;
|
|
9
|
+
headers?: AllowedHeaders;
|
|
10
|
+
subscriptions?: boolean;
|
|
11
|
+
uri?: string;
|
|
12
|
+
auditUserId?: string;
|
|
13
|
+
credentials?: RequestCredentials;
|
|
14
|
+
};
|
package/src/wrap.ts
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { GQtyClient, ResolveOptions, SubscriptionsClient } from 'gqty';
|
|
2
|
+
import type { GeneratedSchema } from './gqty';
|
|
3
|
+
|
|
4
|
+
export type ResolveOptionsWithSession<T> = ResolveOptions<T>;
|
|
5
|
+
|
|
6
|
+
type Client = GQtyClient<GeneratedSchema>;
|
|
7
|
+
export function wrapGraphQLClient(
|
|
8
|
+
getClient: () => Client,
|
|
9
|
+
subscriptionsClient?: SubscriptionsClient
|
|
10
|
+
) {
|
|
11
|
+
return {
|
|
12
|
+
get client() {
|
|
13
|
+
return getClient();
|
|
14
|
+
},
|
|
15
|
+
subscriptionsClient,
|
|
16
|
+
async mutate<T = unknown>(
|
|
17
|
+
resolved: (sub: Client['mutation']) => T,
|
|
18
|
+
options?: ResolveOptionsWithSession<T>
|
|
19
|
+
) {
|
|
20
|
+
if (!options) options = {};
|
|
21
|
+
if (options.noCache === undefined) options.noCache = true;
|
|
22
|
+
|
|
23
|
+
const client = getClient();
|
|
24
|
+
const result = await client.resolved(
|
|
25
|
+
() => resolved(client.mutation),
|
|
26
|
+
options
|
|
27
|
+
);
|
|
28
|
+
return result;
|
|
29
|
+
},
|
|
30
|
+
async query<T = unknown>(
|
|
31
|
+
resolved: (sub: Client['query']) => T,
|
|
32
|
+
options?: ResolveOptionsWithSession<T>
|
|
33
|
+
) {
|
|
34
|
+
const client = getClient();
|
|
35
|
+
const result = await client.resolved(
|
|
36
|
+
() => resolved(client.query),
|
|
37
|
+
options
|
|
38
|
+
);
|
|
39
|
+
return result;
|
|
40
|
+
},
|
|
41
|
+
subscribe<T = unknown>(
|
|
42
|
+
resolved: (sub: Client['subscription']) => T,
|
|
43
|
+
onData: (data: T, unsubscribeFn: () => Promise<void>) => void,
|
|
44
|
+
onError?: (err: Error, unsubscribeFn: () => Promise<void>) => void
|
|
45
|
+
) {
|
|
46
|
+
if (!subscriptionsClient) throw new Error('Subscriptions not enabled');
|
|
47
|
+
let unsub: undefined | (() => Promise<void>);
|
|
48
|
+
|
|
49
|
+
const stop = async () => {
|
|
50
|
+
if (!unsub) return;
|
|
51
|
+
await unsub().catch(() => undefined);
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const client = getClient();
|
|
55
|
+
client.resolved(() => resolved(client.subscription), {
|
|
56
|
+
onSubscription(event) {
|
|
57
|
+
if (event.unsubscribe) unsub = event.unsubscribe;
|
|
58
|
+
|
|
59
|
+
if (event.type === 'data') onData(event.data, stop);
|
|
60
|
+
else if (event.type === 'with-errors' && onError)
|
|
61
|
+
onError(event.error, stop);
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
return stop;
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
}
|