@vrplatform/graphql 1.0.3 → 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.
Files changed (54) hide show
  1. package/build/main/create-client.d.ts +4 -8
  2. package/build/main/create-client.js +16 -33
  3. package/build/main/index.d.ts +13 -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 +4 -8
  8. package/build/module/create-client.js +13 -27
  9. package/build/module/index.d.ts +13 -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 +10 -6
  15. package/build/main/create-client-v2.d.ts +0 -11
  16. package/build/main/create-client-v2.js +0 -79
  17. package/build/main/dotenv.d.ts +0 -1
  18. package/build/main/dotenv.js +0 -6
  19. package/build/main/src/constants.d.ts +0 -2
  20. package/build/main/src/constants.js +0 -5
  21. package/build/main/src/create-client.d.ts +0 -7
  22. package/build/main/src/create-client.js +0 -106
  23. package/build/main/src/gqty/index.d.ts +0 -1
  24. package/build/main/src/gqty/index.js +0 -17
  25. package/build/main/src/gqty/schema.generated.d.ts +0 -147429
  26. package/build/main/src/gqty/schema.generated.js +0 -47182
  27. package/build/main/src/index.d.ts +0 -14
  28. package/build/main/src/index.js +0 -93
  29. package/build/main/src/index.spec.d.ts +0 -1
  30. package/build/main/src/index.spec.js +0 -12
  31. package/build/main/src/types.d.ts +0 -16
  32. package/build/main/src/types.js +0 -2
  33. package/build/main/wrap.d.ts +0 -10
  34. package/build/main/wrap.js +0 -70
  35. package/build/module/create-client-v2.d.ts +0 -11
  36. package/build/module/create-client-v2.js +0 -72
  37. package/build/module/dotenv.d.ts +0 -1
  38. package/build/module/dotenv.js +0 -3
  39. package/build/module/src/constants.d.ts +0 -2
  40. package/build/module/src/constants.js +0 -2
  41. package/build/module/src/create-client.d.ts +0 -7
  42. package/build/module/src/create-client.js +0 -103
  43. package/build/module/src/gqty/index.d.ts +0 -1
  44. package/build/module/src/gqty/index.js +0 -1
  45. package/build/module/src/gqty/schema.generated.d.ts +0 -147429
  46. package/build/module/src/gqty/schema.generated.js +0 -47179
  47. package/build/module/src/index.d.ts +0 -14
  48. package/build/module/src/index.js +0 -73
  49. package/build/module/src/index.spec.d.ts +0 -1
  50. package/build/module/src/index.spec.js +0 -10
  51. package/build/module/src/types.d.ts +0 -16
  52. package/build/module/src/types.js +0 -1
  53. package/build/module/wrap.d.ts +0 -10
  54. package/build/module/wrap.js +0 -67
@@ -1,106 +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
- const json = await response.json();
55
- return json; //await defaultResponseHandler(json);
56
- };
57
- const subscriptionsClient = args?.subscriptions === true
58
- ? (0, subscriptions_1.createSubscriptionsClient)({
59
- lazy: true,
60
- connectionInitPayload: async () => ({
61
- headers: await getHeaders({
62
- [constants_1.hasuraQueryTypeHeader]: 'subscription',
63
- }),
64
- }),
65
- wsEndpoint() {
66
- const wsUrl = new URL(uri);
67
- wsUrl.protocol = wsUrl.protocol
68
- .replace('https', 'wss')
69
- .replace('http', 'ws');
70
- return wsUrl.href;
71
- },
72
- /*url: () => {
73
- },*/
74
- })
75
- : undefined;
76
- const cache = new gqty_1.Cache(undefined, {
77
- maxAge: 0,
78
- staleWhileRevalidate: 0,
79
- normalization: false,
80
- });
81
- const client = (0, gqty_1.createClient)({
82
- schema: gqty_2.generatedSchema,
83
- scalars: gqty_2.scalarsEnumsHash,
84
- //cache,
85
- cache,
86
- fetchOptions: {
87
- fetcher: queryFetcher,
88
- subscriber: subscriptionsClient,
89
- },
90
- });
91
- /*const client: GQtyClient<GeneratedSchema> = createClient<GeneratedSchema>({
92
- schema: generatedSchema,
93
- scalarsEnumsHash,
94
- queryFetcher,
95
- subscriptionsClient,
96
- normalization: args?.normalization === true,
97
- defaults: {
98
- resolved: {
99
- noCache: args?.cache !== true,
100
- retry: false,
101
- },
102
- },
103
- ...args,
104
- });*/
105
- return { subscriptionsClient, client };
106
- }
@@ -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);