@vrplatform/graphql 1.0.4 → 1.0.6

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