@vrplatform/graphql 1.0.4 → 1.0.5
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/create-client.d.ts +4 -8
- package/build/main/create-client.js +16 -33
- package/build/main/index.d.ts +13 -3
- package/build/main/index.js +74 -5
- package/build/main/tsconfig.main.tsbuildinfo +1 -1
- package/build/main/types.d.ts +0 -2
- package/build/module/create-client.d.ts +4 -8
- package/build/module/create-client.js +13 -27
- package/build/module/index.d.ts +13 -3
- package/build/module/index.js +72 -3
- package/build/module/tsconfig.esm.tsbuildinfo +1 -1
- package/build/module/types.d.ts +0 -2
- package/package.json +1 -1
- package/src/create-client.ts +3 -3
- package/build/main/create-client-v2.d.ts +0 -11
- package/build/main/create-client-v2.js +0 -79
- package/build/main/dotenv.d.ts +0 -1
- package/build/main/dotenv.js +0 -6
- package/build/main/src/constants.d.ts +0 -2
- package/build/main/src/constants.js +0 -5
- package/build/main/src/create-client.d.ts +0 -7
- package/build/main/src/create-client.js +0 -105
- package/build/main/src/gqty/index.d.ts +0 -1
- package/build/main/src/gqty/index.js +0 -17
- package/build/main/src/gqty/schema.generated.d.ts +0 -147429
- package/build/main/src/gqty/schema.generated.js +0 -47182
- package/build/main/src/index.d.ts +0 -14
- package/build/main/src/index.js +0 -93
- package/build/main/src/index.spec.d.ts +0 -1
- package/build/main/src/index.spec.js +0 -12
- package/build/main/src/types.d.ts +0 -16
- package/build/main/src/types.js +0 -2
- package/build/main/wrap.d.ts +0 -10
- package/build/main/wrap.js +0 -70
- package/build/module/create-client-v2.d.ts +0 -11
- package/build/module/create-client-v2.js +0 -72
- package/build/module/dotenv.d.ts +0 -1
- package/build/module/dotenv.js +0 -3
- package/build/module/src/constants.d.ts +0 -2
- package/build/module/src/constants.js +0 -2
- package/build/module/src/create-client.d.ts +0 -7
- package/build/module/src/create-client.js +0 -102
- package/build/module/src/gqty/index.d.ts +0 -1
- package/build/module/src/gqty/index.js +0 -1
- package/build/module/src/gqty/schema.generated.d.ts +0 -147429
- package/build/module/src/gqty/schema.generated.js +0 -47179
- package/build/module/src/index.d.ts +0 -14
- package/build/module/src/index.js +0 -73
- package/build/module/src/index.spec.d.ts +0 -1
- package/build/module/src/index.spec.js +0 -10
- package/build/module/src/types.d.ts +0 -16
- package/build/module/src/types.js +0 -1
- package/build/module/wrap.d.ts +0 -10
- package/build/module/wrap.js +0 -67
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export { type HasuraClient, useHasuraClientInner } from './create-client';
|
|
2
|
-
export * from './gqty';
|
|
3
|
-
export { GQtyError } from 'gqty';
|
|
4
|
-
import type { LegacyResolveOptions } from 'gqty';
|
|
5
|
-
import type { Mutation, Query, Subscription } from './gqty';
|
|
6
|
-
import type { GqlAuthParam } from './types';
|
|
7
|
-
export type ResolveOptionsWithSession<T> = LegacyResolveOptions<T>;
|
|
8
|
-
export declare function useHasuraClient(args?: GqlAuthParam): {
|
|
9
|
-
client: import("gqty").GQtyClient<import("./gqty").GeneratedSchema>;
|
|
10
|
-
subscriptionsClient: import("gqty").LegacySubscriptionsClient;
|
|
11
|
-
mutate<T = unknown>(resolved: (sub: Mutation) => T, options?: ResolveOptionsWithSession<T>): Promise<T>;
|
|
12
|
-
query<T = unknown>(resolved: (sub: Query) => T, options?: ResolveOptionsWithSession<T>): Promise<T>;
|
|
13
|
-
subscribe<T = unknown>(resolved: (sub: Subscription) => T, onData: (data: T, unsubscribeFn: () => Promise<void>) => void, onError?: (err: Error, unsubscribeFn: () => Promise<void>) => void): () => Promise<void>;
|
|
14
|
-
};
|
package/build/main/src/index.js
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.GQtyError = exports.useHasuraClientInner = void 0;
|
|
18
|
-
exports.useHasuraClient = useHasuraClient;
|
|
19
|
-
const create_client_1 = require("./create-client");
|
|
20
|
-
var create_client_2 = require("./create-client");
|
|
21
|
-
Object.defineProperty(exports, "useHasuraClientInner", { enumerable: true, get: function () { return create_client_2.useHasuraClientInner; } });
|
|
22
|
-
__exportStar(require("./gqty"), exports);
|
|
23
|
-
var gqty_1 = require("gqty");
|
|
24
|
-
Object.defineProperty(exports, "GQtyError", { enumerable: true, get: function () { return gqty_1.GQtyError; } });
|
|
25
|
-
function useHasuraClient(args) {
|
|
26
|
-
const { client, subscriptionsClient } = (0, create_client_1.useHasuraClientInner)(args);
|
|
27
|
-
const retries = args.retries || 3;
|
|
28
|
-
return {
|
|
29
|
-
client,
|
|
30
|
-
subscriptionsClient,
|
|
31
|
-
async mutate(resolved, options) {
|
|
32
|
-
if (!options)
|
|
33
|
-
options = {};
|
|
34
|
-
if (options.noCache === undefined)
|
|
35
|
-
options.noCache = true;
|
|
36
|
-
let err;
|
|
37
|
-
for (let tries = 1; tries <= retries; tries++) {
|
|
38
|
-
try {
|
|
39
|
-
const result = await client.resolve(({ mutation }) => resolved(mutation), options);
|
|
40
|
-
return result;
|
|
41
|
-
}
|
|
42
|
-
catch (error) {
|
|
43
|
-
err = error;
|
|
44
|
-
if (error.message !== 'database query error')
|
|
45
|
-
break;
|
|
46
|
-
await new Promise((resolve) => setTimeout(resolve, 1000 * tries + 1000));
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
if (args.onError)
|
|
50
|
-
throw args.onError(err) || err;
|
|
51
|
-
throw err;
|
|
52
|
-
},
|
|
53
|
-
async query(resolved, options) {
|
|
54
|
-
let err;
|
|
55
|
-
for (let tries = 1; tries <= retries; tries++) {
|
|
56
|
-
try {
|
|
57
|
-
const result = await client.resolve(({ query }) => resolved(query), options);
|
|
58
|
-
return result;
|
|
59
|
-
}
|
|
60
|
-
catch (error) {
|
|
61
|
-
err = error;
|
|
62
|
-
if (error.message !== 'database query error')
|
|
63
|
-
break;
|
|
64
|
-
await new Promise((resolve) => setTimeout(resolve, 1000 * tries + 1000));
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
if (args.onError)
|
|
68
|
-
throw args.onError(err) || err;
|
|
69
|
-
throw err;
|
|
70
|
-
},
|
|
71
|
-
subscribe(resolved, onData, onError) {
|
|
72
|
-
if (!subscriptionsClient)
|
|
73
|
-
throw new Error('Subscriptions not enabled');
|
|
74
|
-
let unsub;
|
|
75
|
-
const stop = async () => {
|
|
76
|
-
if (!unsub)
|
|
77
|
-
return;
|
|
78
|
-
await unsub().catch(() => undefined);
|
|
79
|
-
};
|
|
80
|
-
client.resolved(() => resolved(client.subscription), {
|
|
81
|
-
onSubscription(event) {
|
|
82
|
-
if (event.unsubscribe)
|
|
83
|
-
unsub = event.unsubscribe;
|
|
84
|
-
if (event.type === 'data')
|
|
85
|
-
onData(event.data, stop);
|
|
86
|
-
else if (event.type === 'with-errors' && onError)
|
|
87
|
-
onError(event.error, stop);
|
|
88
|
-
},
|
|
89
|
-
});
|
|
90
|
-
return stop;
|
|
91
|
-
},
|
|
92
|
-
};
|
|
93
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import '../dotenv';
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
require("../dotenv");
|
|
4
|
-
const bun_test_1 = require("bun:test");
|
|
5
|
-
const index_1 = require("./index");
|
|
6
|
-
(0, bun_test_1.test)('test', async () => {
|
|
7
|
-
const client = (0, index_1.useHasuraClient)({
|
|
8
|
-
secret: process.env.HASURA_GRAPHQL_ADMIN_SECRET,
|
|
9
|
-
});
|
|
10
|
-
const user = await client.query((q) => q.user({ limit: 5 }).map((x) => x.id));
|
|
11
|
-
(0, bun_test_1.expect)(user.length).toBeTruthy();
|
|
12
|
-
});
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export type Headers = {
|
|
2
|
-
[s: string]: string;
|
|
3
|
-
};
|
|
4
|
-
export type GqlAuthParam = {
|
|
5
|
-
accessToken?: string;
|
|
6
|
-
secret?: string;
|
|
7
|
-
headers?: {
|
|
8
|
-
[s: string]: string;
|
|
9
|
-
} | (() => Headers) | (() => Promise<Headers>);
|
|
10
|
-
fetch?: any;
|
|
11
|
-
subscriptions?: boolean;
|
|
12
|
-
uri?: string;
|
|
13
|
-
onError?: (err: Error) => any;
|
|
14
|
-
retries?: number;
|
|
15
|
-
auditUserId?: string;
|
|
16
|
-
};
|
package/build/main/src/types.js
DELETED
package/build/main/wrap.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { GQtyClient, LegacyResolveOptions, LegacySubscriptionsClient } from 'gqty';
|
|
2
|
-
import type { GeneratedSchema, Mutation, Query, Subscription } from './gqty';
|
|
3
|
-
export type ResolveOptionsWithSession<T> = LegacyResolveOptions<T>;
|
|
4
|
-
export declare function wrapGraphQLClient(client: GQtyClient<GeneratedSchema>, subscriptionsClient?: LegacySubscriptionsClient, onError?: (err: Error) => any, retries?: number): {
|
|
5
|
-
client: GQtyClient<GeneratedSchema>;
|
|
6
|
-
subscriptionsClient: LegacySubscriptionsClient;
|
|
7
|
-
mutate<T = unknown>(resolved: (sub: Mutation) => T, options?: ResolveOptionsWithSession<T>): Promise<T>;
|
|
8
|
-
query<T = unknown>(resolved: (sub: Query) => T, options?: ResolveOptionsWithSession<T>): Promise<T>;
|
|
9
|
-
subscribe<T = unknown>(resolved: (sub: Subscription) => T, onData: (data: T, unsubscribeFn: () => Promise<void>) => void, onError?: (err: Error, unsubscribeFn: () => Promise<void>) => void): () => Promise<void>;
|
|
10
|
-
};
|
package/build/main/wrap.js
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.wrapGraphQLClient = wrapGraphQLClient;
|
|
4
|
-
function wrapGraphQLClient(client, subscriptionsClient, onError, retries = 3) {
|
|
5
|
-
return {
|
|
6
|
-
client,
|
|
7
|
-
subscriptionsClient,
|
|
8
|
-
async mutate(resolved, options) {
|
|
9
|
-
if (!options)
|
|
10
|
-
options = {};
|
|
11
|
-
if (options.noCache === undefined)
|
|
12
|
-
options.noCache = true;
|
|
13
|
-
let err;
|
|
14
|
-
for (let tries = 1; tries <= retries; tries++) {
|
|
15
|
-
try {
|
|
16
|
-
const result = await client.resolve(({ mutation }) => resolved(mutation), options);
|
|
17
|
-
return result;
|
|
18
|
-
}
|
|
19
|
-
catch (error) {
|
|
20
|
-
err = error;
|
|
21
|
-
if (error.message !== 'database query error')
|
|
22
|
-
break;
|
|
23
|
-
await new Promise((resolve) => setTimeout(resolve, 1000 * tries + 1000));
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
if (onError)
|
|
27
|
-
throw onError(err) || err;
|
|
28
|
-
throw err;
|
|
29
|
-
},
|
|
30
|
-
async query(resolved, options) {
|
|
31
|
-
let err;
|
|
32
|
-
for (let tries = 1; tries <= retries; tries++) {
|
|
33
|
-
try {
|
|
34
|
-
const result = await client.resolve(({ query }) => resolved(query), options);
|
|
35
|
-
return result;
|
|
36
|
-
}
|
|
37
|
-
catch (error) {
|
|
38
|
-
err = error;
|
|
39
|
-
if (error.message !== 'database query error')
|
|
40
|
-
break;
|
|
41
|
-
await new Promise((resolve) => setTimeout(resolve, 1000 * tries + 1000));
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
if (onError)
|
|
45
|
-
throw onError(err) || err;
|
|
46
|
-
throw err;
|
|
47
|
-
},
|
|
48
|
-
subscribe(resolved, onData, onError) {
|
|
49
|
-
if (!subscriptionsClient)
|
|
50
|
-
throw new Error('Subscriptions not enabled');
|
|
51
|
-
let unsub;
|
|
52
|
-
const stop = async () => {
|
|
53
|
-
if (!unsub)
|
|
54
|
-
return;
|
|
55
|
-
await unsub().catch(() => undefined);
|
|
56
|
-
};
|
|
57
|
-
client.resolved(() => resolved(client.subscription), {
|
|
58
|
-
onSubscription(event) {
|
|
59
|
-
if (event.unsubscribe)
|
|
60
|
-
unsub = event.unsubscribe;
|
|
61
|
-
if (event.type === 'data')
|
|
62
|
-
onData(event.data, stop);
|
|
63
|
-
else if (event.type === 'with-errors' && onError)
|
|
64
|
-
onError(event.error, stop);
|
|
65
|
-
},
|
|
66
|
-
});
|
|
67
|
-
return stop;
|
|
68
|
-
},
|
|
69
|
-
};
|
|
70
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { type GQtyClient, type SubscriptionsClient } from 'gqty';
|
|
2
|
-
import { type GeneratedSchema } from './gqty';
|
|
3
|
-
import type { GqlAuthParam } from './types';
|
|
4
|
-
export type GqlClientV2 = ReturnType<typeof createClientV2>;
|
|
5
|
-
export declare function createClientV2(graphqlUri: string, args?: GqlAuthParam): {
|
|
6
|
-
client: GQtyClient<GeneratedSchema>;
|
|
7
|
-
subscriptionsClient: SubscriptionsClient;
|
|
8
|
-
mutate<T = unknown>(resolved: (sub: import("./gqty").Mutation) => T, options?: import("./wrap").ResolveOptionsWithSession<T>): Promise<T>;
|
|
9
|
-
query<T_1 = unknown>(resolved: (sub: import("./gqty").Query) => T_1, options?: import("./wrap").ResolveOptionsWithSession<T_1>): Promise<T_1>;
|
|
10
|
-
subscribe<T_2 = unknown>(resolved: (sub: import("./gqty").Subscription) => T_2, onData: (data: T_2, unsubscribeFn: () => Promise<void>) => void, onError?: (err: Error, unsubscribeFn: () => Promise<void>) => void): () => Promise<void>;
|
|
11
|
-
};
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { createSubscriptionsClient } from '@gqty/subscriptions';
|
|
2
|
-
import fetch from 'cross-fetch';
|
|
3
|
-
import { createClient, } from 'gqty';
|
|
4
|
-
import { generatedSchema, scalarsEnumsHash, } from './gqty';
|
|
5
|
-
import { wrapGraphQLClient } from './wrap';
|
|
6
|
-
export function createClientV2(graphqlUri, args) {
|
|
7
|
-
const $headers = args && 'headers' in args ? args.headers : undefined;
|
|
8
|
-
const $fetch = (args && 'fetch' in args ? args.fetch : undefined) || fetch;
|
|
9
|
-
const getHeaders = $headers && typeof $headers === 'function'
|
|
10
|
-
? () => Promise.resolve($headers())
|
|
11
|
-
: async () => {
|
|
12
|
-
const headers = $headers || {};
|
|
13
|
-
if (args && 'secret' in args) {
|
|
14
|
-
headers['x-hasura-admin-secret'] = args.secret;
|
|
15
|
-
}
|
|
16
|
-
else if (args && 'accessToken' in args && args.accessToken) {
|
|
17
|
-
headers.authorization = args.accessToken.startsWith('Bearer ')
|
|
18
|
-
? args.accessToken
|
|
19
|
-
: `Bearer ${args.accessToken}`;
|
|
20
|
-
}
|
|
21
|
-
return headers;
|
|
22
|
-
};
|
|
23
|
-
const queryFetcher = async (query, variables, fetchOptions) => {
|
|
24
|
-
const headers = await getHeaders();
|
|
25
|
-
if (fetchOptions?.headers) {
|
|
26
|
-
for (const key in fetchOptions.headers) {
|
|
27
|
-
headers[key] = fetchOptions.headers[key];
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
const response = await $fetch(graphqlUri, {
|
|
31
|
-
method: 'POST',
|
|
32
|
-
headers: {
|
|
33
|
-
'Content-Type': 'application/json',
|
|
34
|
-
...headers,
|
|
35
|
-
},
|
|
36
|
-
body: JSON.stringify({
|
|
37
|
-
query,
|
|
38
|
-
variables,
|
|
39
|
-
}),
|
|
40
|
-
});
|
|
41
|
-
const json = await response.json();
|
|
42
|
-
return json;
|
|
43
|
-
};
|
|
44
|
-
const subscriptionsClient = (() => {
|
|
45
|
-
if (args?.subscriptions === false)
|
|
46
|
-
return;
|
|
47
|
-
const wsUrl = new URL(graphqlUri);
|
|
48
|
-
wsUrl.protocol = wsUrl.protocol
|
|
49
|
-
.replace('https', 'wss')
|
|
50
|
-
.replace('http', 'ws');
|
|
51
|
-
const subscriptionsClient = createSubscriptionsClient({
|
|
52
|
-
wsEndpoint: wsUrl.href,
|
|
53
|
-
connectionInitPayload: async () => ({ headers: await getHeaders() }),
|
|
54
|
-
});
|
|
55
|
-
return subscriptionsClient;
|
|
56
|
-
})();
|
|
57
|
-
const client = createClient({
|
|
58
|
-
schema: generatedSchema,
|
|
59
|
-
scalarsEnumsHash,
|
|
60
|
-
queryFetcher,
|
|
61
|
-
subscriptionsClient,
|
|
62
|
-
normalization: args?.normalization !== false,
|
|
63
|
-
defaults: {
|
|
64
|
-
resolved: {
|
|
65
|
-
noCache: args?.cache ? false : true,
|
|
66
|
-
retry: false,
|
|
67
|
-
},
|
|
68
|
-
},
|
|
69
|
-
...args,
|
|
70
|
-
});
|
|
71
|
-
return wrapGraphQLClient(client, subscriptionsClient, args?.onError);
|
|
72
|
-
}
|
package/build/module/dotenv.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const env: import("dotenv").DotenvParseOutput;
|
package/build/module/dotenv.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { type GeneratedSchema } from './gqty';
|
|
2
|
-
import type { GqlAuthParam } from './types';
|
|
3
|
-
export type HasuraClient = ReturnType<typeof useHasuraClientInner>;
|
|
4
|
-
export declare function useHasuraClientInner(args?: Omit<GqlAuthParam, 'retries'>): {
|
|
5
|
-
subscriptionsClient: import("gqty").LegacySubscriptionsClient;
|
|
6
|
-
client: import("gqty").GQtyClient<GeneratedSchema>;
|
|
7
|
-
};
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import { createSubscriptionsClient } from '@gqty/subscriptions';
|
|
2
|
-
// import fetch from 'cross-fetch';
|
|
3
|
-
import { Cache, createClient, defaultResponseHandler, } from 'gqty';
|
|
4
|
-
import { hasuraGraphqlUri, hasuraQueryTypeHeader } from './constants';
|
|
5
|
-
import { generatedSchema, scalarsEnumsHash, } from './gqty';
|
|
6
|
-
export function useHasuraClientInner(args) {
|
|
7
|
-
const $headers = args && 'headers' in args ? args.headers : undefined;
|
|
8
|
-
const $fetch = (args && 'fetch' in args ? args.fetch : undefined) || fetch;
|
|
9
|
-
const uri = args?.uri || hasuraGraphqlUri;
|
|
10
|
-
const getHeaders = async (base) => {
|
|
11
|
-
const headers = ($headers && typeof $headers === 'function'
|
|
12
|
-
? await $headers()
|
|
13
|
-
: $headers) || {};
|
|
14
|
-
if (base)
|
|
15
|
-
for (const key in base)
|
|
16
|
-
headers[key] = base[key];
|
|
17
|
-
if (args && 'secret' in args && args.secret) {
|
|
18
|
-
headers['x-hasura-admin-secret'] = args.secret;
|
|
19
|
-
}
|
|
20
|
-
else if (args && 'accessToken' in args && args.accessToken) {
|
|
21
|
-
headers.authorization = args.accessToken.startsWith('Bearer ')
|
|
22
|
-
? args.accessToken
|
|
23
|
-
: `Bearer ${args.accessToken}`;
|
|
24
|
-
}
|
|
25
|
-
if (args?.auditUserId)
|
|
26
|
-
headers['x-hasura-audit-user-id'] = args.auditUserId;
|
|
27
|
-
return headers;
|
|
28
|
-
};
|
|
29
|
-
const queryFetcher = async ({ query, variables, operationName }, fetchOptions) => {
|
|
30
|
-
const headers = await getHeaders();
|
|
31
|
-
if (fetchOptions?.headers) {
|
|
32
|
-
for (const key in fetchOptions.headers) {
|
|
33
|
-
headers[key] = fetchOptions.headers[key];
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
// Modify "https://finalytic.hasura.app/v1/graphql" if needed
|
|
37
|
-
const response = await $fetch('https://finalytic.hasura.app/v1/graphql', {
|
|
38
|
-
...fetchOptions,
|
|
39
|
-
method: 'POST',
|
|
40
|
-
headers: {
|
|
41
|
-
'Content-Type': 'application/json',
|
|
42
|
-
...headers,
|
|
43
|
-
},
|
|
44
|
-
body: JSON.stringify({
|
|
45
|
-
query,
|
|
46
|
-
variables,
|
|
47
|
-
operationName,
|
|
48
|
-
}),
|
|
49
|
-
mode: 'cors',
|
|
50
|
-
});
|
|
51
|
-
return await defaultResponseHandler(response);
|
|
52
|
-
};
|
|
53
|
-
const subscriptionsClient = args?.subscriptions === true
|
|
54
|
-
? createSubscriptionsClient({
|
|
55
|
-
lazy: true,
|
|
56
|
-
connectionInitPayload: async () => ({
|
|
57
|
-
headers: await getHeaders({
|
|
58
|
-
[hasuraQueryTypeHeader]: 'subscription',
|
|
59
|
-
}),
|
|
60
|
-
}),
|
|
61
|
-
wsEndpoint() {
|
|
62
|
-
const wsUrl = new URL(uri);
|
|
63
|
-
wsUrl.protocol = wsUrl.protocol
|
|
64
|
-
.replace('https', 'wss')
|
|
65
|
-
.replace('http', 'ws');
|
|
66
|
-
return wsUrl.href;
|
|
67
|
-
},
|
|
68
|
-
/*url: () => {
|
|
69
|
-
},*/
|
|
70
|
-
})
|
|
71
|
-
: undefined;
|
|
72
|
-
const cache = new Cache(undefined, {
|
|
73
|
-
maxAge: 0,
|
|
74
|
-
staleWhileRevalidate: 0,
|
|
75
|
-
normalization: false,
|
|
76
|
-
});
|
|
77
|
-
const client = createClient({
|
|
78
|
-
schema: generatedSchema,
|
|
79
|
-
scalars: scalarsEnumsHash,
|
|
80
|
-
//cache,
|
|
81
|
-
cache,
|
|
82
|
-
fetchOptions: {
|
|
83
|
-
fetcher: queryFetcher,
|
|
84
|
-
subscriber: subscriptionsClient,
|
|
85
|
-
},
|
|
86
|
-
});
|
|
87
|
-
/*const client: GQtyClient<GeneratedSchema> = createClient<GeneratedSchema>({
|
|
88
|
-
schema: generatedSchema,
|
|
89
|
-
scalarsEnumsHash,
|
|
90
|
-
queryFetcher,
|
|
91
|
-
subscriptionsClient,
|
|
92
|
-
normalization: args?.normalization === true,
|
|
93
|
-
defaults: {
|
|
94
|
-
resolved: {
|
|
95
|
-
noCache: args?.cache !== true,
|
|
96
|
-
retry: false,
|
|
97
|
-
},
|
|
98
|
-
},
|
|
99
|
-
...args,
|
|
100
|
-
});*/
|
|
101
|
-
return { subscriptionsClient, client };
|
|
102
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './schema.generated';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './schema.generated';
|