@vrplatform/graphql 1.0.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.
Files changed (75) hide show
  1. package/LICENSE +3 -0
  2. package/build/main/constants.d.ts +2 -0
  3. package/build/main/constants.js +5 -0
  4. package/build/main/create-client-v2.d.ts +11 -0
  5. package/build/main/create-client-v2.js +79 -0
  6. package/build/main/create-client.d.ts +11 -0
  7. package/build/main/create-client.js +122 -0
  8. package/build/main/dotenv.d.ts +1 -0
  9. package/build/main/dotenv.js +6 -0
  10. package/build/main/gqty/index.d.ts +1 -0
  11. package/build/main/gqty/index.js +17 -0
  12. package/build/main/gqty/schema.generated.d.ts +117383 -0
  13. package/build/main/gqty/schema.generated.js +47182 -0
  14. package/build/main/index.d.ts +4 -0
  15. package/build/main/index.js +24 -0
  16. package/build/main/src/constants.d.ts +2 -0
  17. package/build/main/src/constants.js +5 -0
  18. package/build/main/src/create-client.d.ts +7 -0
  19. package/build/main/src/create-client.js +109 -0
  20. package/build/main/src/gqty/index.d.ts +1 -0
  21. package/build/main/src/gqty/index.js +17 -0
  22. package/build/main/src/gqty/schema.generated.d.ts +147429 -0
  23. package/build/main/src/gqty/schema.generated.js +47182 -0
  24. package/build/main/src/index.d.ts +14 -0
  25. package/build/main/src/index.js +93 -0
  26. package/build/main/src/index.spec.d.ts +1 -0
  27. package/build/main/src/index.spec.js +12 -0
  28. package/build/main/src/types.d.ts +16 -0
  29. package/build/main/src/types.js +2 -0
  30. package/build/main/tsconfig.main.tsbuildinfo +1 -0
  31. package/build/main/types.d.ts +18 -0
  32. package/build/main/types.js +2 -0
  33. package/build/main/wrap.d.ts +10 -0
  34. package/build/main/wrap.js +70 -0
  35. package/build/module/constants.d.ts +2 -0
  36. package/build/module/constants.js +2 -0
  37. package/build/module/create-client-v2.d.ts +11 -0
  38. package/build/module/create-client-v2.js +72 -0
  39. package/build/module/create-client.d.ts +11 -0
  40. package/build/module/create-client.js +116 -0
  41. package/build/module/dotenv.d.ts +1 -0
  42. package/build/module/dotenv.js +3 -0
  43. package/build/module/gqty/index.d.ts +1 -0
  44. package/build/module/gqty/index.js +1 -0
  45. package/build/module/gqty/schema.generated.d.ts +117383 -0
  46. package/build/module/gqty/schema.generated.js +47179 -0
  47. package/build/module/index.d.ts +4 -0
  48. package/build/module/index.js +4 -0
  49. package/build/module/src/constants.d.ts +2 -0
  50. package/build/module/src/constants.js +2 -0
  51. package/build/module/src/create-client.d.ts +7 -0
  52. package/build/module/src/create-client.js +103 -0
  53. package/build/module/src/gqty/index.d.ts +1 -0
  54. package/build/module/src/gqty/index.js +1 -0
  55. package/build/module/src/gqty/schema.generated.d.ts +147429 -0
  56. package/build/module/src/gqty/schema.generated.js +47179 -0
  57. package/build/module/src/index.d.ts +14 -0
  58. package/build/module/src/index.js +73 -0
  59. package/build/module/src/index.spec.d.ts +1 -0
  60. package/build/module/src/index.spec.js +10 -0
  61. package/build/module/src/types.d.ts +16 -0
  62. package/build/module/src/types.js +1 -0
  63. package/build/module/tsconfig.esm.tsbuildinfo +1 -0
  64. package/build/module/types.d.ts +18 -0
  65. package/build/module/types.js +1 -0
  66. package/build/module/wrap.d.ts +10 -0
  67. package/build/module/wrap.js +67 -0
  68. package/package.json +66 -0
  69. package/src/constants.ts +2 -0
  70. package/src/create-client.ts +121 -0
  71. package/src/gqty/index.ts +1 -0
  72. package/src/gqty/schema.generated.d.ts +117383 -0
  73. package/src/gqty/schema.generated.js +47255 -0
  74. package/src/index.ts +93 -0
  75. package/src/types.ts +18 -0
@@ -0,0 +1,4 @@
1
+ export { type ResolveOptionsWithSession, wrapGraphQLClient } from './wrap';
2
+ export { type HasuraClient, useHasuraClient } from './create-client';
3
+ export * from './gqty';
4
+ export { GQtyClient, LegacySubscriptionsClient as SubscriptionsClient, LegacyResolveOptions as ResolveOptions, GQtyError, } from 'gqty';
@@ -0,0 +1,24 @@
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.useHasuraClient = exports.wrapGraphQLClient = void 0;
18
+ var wrap_1 = require("./wrap");
19
+ Object.defineProperty(exports, "wrapGraphQLClient", { enumerable: true, get: function () { return wrap_1.wrapGraphQLClient; } });
20
+ var create_client_1 = require("./create-client");
21
+ Object.defineProperty(exports, "useHasuraClient", { enumerable: true, get: function () { return create_client_1.useHasuraClient; } });
22
+ __exportStar(require("./gqty"), exports);
23
+ var gqty_1 = require("gqty");
24
+ Object.defineProperty(exports, "GQtyError", { enumerable: true, get: function () { return gqty_1.GQtyError; } });
@@ -0,0 +1,2 @@
1
+ export declare const hasuraGraphqlUri = "https://finalytic.hasura.app/v1/graphql";
2
+ export declare const hasuraQueryTypeHeader = "x-hasura-query-type";
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.hasuraQueryTypeHeader = exports.hasuraGraphqlUri = void 0;
4
+ exports.hasuraGraphqlUri = 'https://finalytic.hasura.app/v1/graphql'; // 'https://hasura.vrplatform.app/v1/graphql';
5
+ exports.hasuraQueryTypeHeader = 'x-hasura-query-type';
@@ -0,0 +1,7 @@
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
+ };
@@ -0,0 +1,109 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.useHasuraClientInner = useHasuraClientInner;
7
+ const subscriptions_1 = require("@gqty/subscriptions");
8
+ const cross_fetch_1 = __importDefault(require("cross-fetch"));
9
+ const gqty_1 = require("gqty");
10
+ const constants_1 = require("./constants");
11
+ const gqty_2 = require("./gqty");
12
+ function useHasuraClientInner(args) {
13
+ const $headers = args && 'headers' in args ? args.headers : undefined;
14
+ const $fetch = (args && 'fetch' in args ? args.fetch : undefined) || cross_fetch_1.default;
15
+ const uri = args?.uri || constants_1.hasuraGraphqlUri;
16
+ const getHeaders = async (base) => {
17
+ const headers = ($headers && typeof $headers === 'function'
18
+ ? await $headers()
19
+ : $headers) || {};
20
+ if (base)
21
+ for (const key in base)
22
+ headers[key] = base[key];
23
+ if (args && 'secret' in args && args.secret) {
24
+ headers['x-hasura-admin-secret'] = args.secret;
25
+ }
26
+ else if (args && 'accessToken' in args && args.accessToken) {
27
+ headers.authorization = args.accessToken.startsWith('Bearer ')
28
+ ? args.accessToken
29
+ : `Bearer ${args.accessToken}`;
30
+ }
31
+ if (args?.auditUserId)
32
+ headers['x-hasura-audit-user-id'] = args.auditUserId;
33
+ return headers;
34
+ };
35
+ const queryFetcher = async ({ query, variables, operationName }, fetchOptions) => {
36
+ const headers = await getHeaders();
37
+ if (fetchOptions?.headers) {
38
+ for (const key in fetchOptions.headers) {
39
+ headers[key] = fetchOptions.headers[key];
40
+ }
41
+ }
42
+ // Modify "https://finalytic.hasura.app/v1/graphql" if needed
43
+ const response = await $fetch('https://finalytic.hasura.app/v1/graphql', {
44
+ ...fetchOptions,
45
+ method: 'POST',
46
+ headers: {
47
+ 'Content-Type': 'application/json',
48
+ ...headers,
49
+ },
50
+ body: JSON.stringify({
51
+ query,
52
+ variables,
53
+ operationName,
54
+ }),
55
+ mode: 'cors',
56
+ });
57
+ const json = await response.json();
58
+ return json; //await defaultResponseHandler(json);
59
+ };
60
+ const subscriptionsClient = args?.subscriptions === true
61
+ ? (0, subscriptions_1.createSubscriptionsClient)({
62
+ lazy: true,
63
+ connectionInitPayload: async () => ({
64
+ headers: await getHeaders({
65
+ [constants_1.hasuraQueryTypeHeader]: 'subscription',
66
+ }),
67
+ }),
68
+ wsEndpoint() {
69
+ const wsUrl = new URL(uri);
70
+ wsUrl.protocol = wsUrl.protocol
71
+ .replace('https', 'wss')
72
+ .replace('http', 'ws');
73
+ return wsUrl.href;
74
+ },
75
+ /*url: () => {
76
+ },*/
77
+ })
78
+ : undefined;
79
+ const cache = new gqty_1.Cache(undefined, {
80
+ maxAge: 0,
81
+ staleWhileRevalidate: 0,
82
+ normalization: false,
83
+ });
84
+ const client = (0, gqty_1.createClient)({
85
+ schema: gqty_2.generatedSchema,
86
+ scalars: gqty_2.scalarsEnumsHash,
87
+ //cache,
88
+ cache,
89
+ fetchOptions: {
90
+ fetcher: queryFetcher,
91
+ subscriber: subscriptionsClient,
92
+ },
93
+ });
94
+ /*const client: GQtyClient<GeneratedSchema> = createClient<GeneratedSchema>({
95
+ schema: generatedSchema,
96
+ scalarsEnumsHash,
97
+ queryFetcher,
98
+ subscriptionsClient,
99
+ normalization: args?.normalization === true,
100
+ defaults: {
101
+ resolved: {
102
+ noCache: args?.cache !== true,
103
+ retry: false,
104
+ },
105
+ },
106
+ ...args,
107
+ });*/
108
+ return { subscriptionsClient, client };
109
+ }
@@ -0,0 +1 @@
1
+ export * from './schema.generated';
@@ -0,0 +1,17 @@
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
+ __exportStar(require("./schema.generated"), exports);