@vrplatform/graphql 1.0.8 → 1.1.2

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 (88) hide show
  1. package/build/main/client/headers.d.ts +3 -0
  2. package/build/main/client/headers.js +42 -0
  3. package/build/main/client/index.d.ts +13 -0
  4. package/build/main/client/index.js +103 -0
  5. package/build/main/client/subscription.d.ts +3 -0
  6. package/build/main/client/subscription.js +29 -0
  7. package/build/main/common/account.d.ts +2 -0
  8. package/build/main/common/account.js +7 -0
  9. package/build/main/common/address.d.ts +9 -0
  10. package/build/main/common/address.js +2 -0
  11. package/build/main/common/bank-record.d.ts +2 -0
  12. package/build/main/common/bank-record.js +7 -0
  13. package/build/main/common/index.d.ts +5 -0
  14. package/build/main/common/index.js +21 -0
  15. package/build/main/common/listings.d.ts +4 -0
  16. package/build/main/common/listings.js +99 -0
  17. package/build/main/common/tenant.d.ts +19 -0
  18. package/build/main/common/tenant.js +85 -0
  19. package/build/main/error.d.ts +2 -0
  20. package/build/main/error.js +6 -0
  21. package/build/main/gqty/index.d.ts +7 -0
  22. package/build/main/gqty/index.js +48 -0
  23. package/build/main/gqty/schema.generated.d.ts +39464 -46636
  24. package/build/main/gqty/schema.generated.js +10450 -14093
  25. package/build/main/index.d.ts +4 -14
  26. package/build/main/index.js +7 -75
  27. package/build/main/tsconfig.main.tsbuildinfo +1 -1
  28. package/build/main/types.d.ts +5 -6
  29. package/build/main/wrap.d.ts +12 -0
  30. package/build/main/wrap.js +47 -0
  31. package/build/module/client/headers.d.ts +3 -0
  32. package/build/module/client/headers.js +39 -0
  33. package/build/module/client/index.d.ts +13 -0
  34. package/build/module/client/index.js +98 -0
  35. package/build/module/client/subscription.d.ts +3 -0
  36. package/build/module/client/subscription.js +26 -0
  37. package/build/module/common/account.d.ts +2 -0
  38. package/build/module/common/account.js +4 -0
  39. package/build/module/common/address.d.ts +9 -0
  40. package/build/module/common/address.js +1 -0
  41. package/build/module/common/bank-record.d.ts +2 -0
  42. package/build/module/common/bank-record.js +4 -0
  43. package/build/module/common/index.d.ts +5 -0
  44. package/build/module/common/index.js +5 -0
  45. package/build/module/common/listings.d.ts +4 -0
  46. package/build/module/common/listings.js +93 -0
  47. package/build/module/common/tenant.d.ts +19 -0
  48. package/build/module/common/tenant.js +77 -0
  49. package/build/module/error.d.ts +2 -0
  50. package/build/module/error.js +2 -0
  51. package/build/module/gqty/index.d.ts +7 -0
  52. package/build/module/gqty/index.js +41 -0
  53. package/build/module/gqty/schema.generated.d.ts +39464 -46636
  54. package/build/module/gqty/schema.generated.js +10450 -14093
  55. package/build/module/index.d.ts +4 -14
  56. package/build/module/index.js +4 -72
  57. package/build/module/tsconfig.esm.tsbuildinfo +1 -1
  58. package/build/module/types.d.ts +5 -6
  59. package/build/module/wrap.d.ts +12 -0
  60. package/build/module/wrap.js +44 -0
  61. package/package.json +25 -35
  62. package/src/client/headers.ts +51 -0
  63. package/src/client/index.ts +152 -0
  64. package/src/client/subscription.ts +34 -0
  65. package/src/common/account.ts +6 -0
  66. package/src/common/address.ts +9 -0
  67. package/src/common/bank-record.ts +6 -0
  68. package/src/common/index.ts +5 -0
  69. package/src/common/listings.ts +106 -0
  70. package/src/common/tenant.ts +101 -0
  71. package/src/error.ts +1 -0
  72. package/src/gqty/index.ts +62 -0
  73. package/src/gqty/schema.generated.d.ts +39464 -46636
  74. package/src/gqty/schema.generated.js +10472 -14099
  75. package/src/index.ts +9 -94
  76. package/src/types.ts +6 -10
  77. package/src/wrap.ts +67 -0
  78. package/LICENSE +0 -3
  79. package/build/main/create-client.d.ts +0 -6
  80. package/build/main/create-client.js +0 -107
  81. package/build/main/gqty/error.d.ts +0 -6
  82. package/build/main/gqty/error.js +0 -48
  83. package/build/module/create-client.d.ts +0 -6
  84. package/build/module/create-client.js +0 -104
  85. package/build/module/gqty/error.d.ts +0 -6
  86. package/build/module/gqty/error.js +0 -40
  87. package/src/create-client.ts +0 -120
  88. package/src/gqty/error.ts +0 -54
package/src/gqty/error.ts DELETED
@@ -1,54 +0,0 @@
1
- import { GQtyError } from 'gqty';
2
- import type { ExecutionResult } from 'graphql';
3
- export const defaultResponseHandler = async (response: Response) => {
4
- const result = await parseResponse(response);
5
- assertExecutionResult(result);
6
- handleResponseErrors(result);
7
- return result;
8
- };
9
- export const parseResponse = async (response: Response) => {
10
- const text = await response.text().then((text) => text.trim() || null);
11
- if (response.status >= 400) {
12
- throw new GQtyError(
13
- `Received HTTP ${response.status} from GraphQL endpoint${
14
- text
15
- ? `, body: ${text.length > 50 ? `${text.slice(0, 50)}...` : text}`
16
- : ''
17
- }.`
18
- );
19
- }
20
- if (!text) {
21
- throw new GQtyError('Received an empty response from GraphQL endpoint.');
22
- }
23
- try {
24
- return JSON.parse(text);
25
- } catch (error) {
26
- throw new GQtyError(
27
- `Received malformed JSON response from GraphQL endpoint: ${
28
- text.length > 50 ? `${text.slice(0, 50)}...` : text
29
- }`
30
- );
31
- }
32
- };
33
- export function assertExecutionResult(
34
- input: unknown
35
- ): asserts input is ExecutionResult {
36
- if (!isExecutionResult(input)) {
37
- throw new GQtyError(
38
- `Expected response to be an ExecutionResult, received: ${JSON.stringify(
39
- input
40
- )}`
41
- );
42
- }
43
- }
44
- export const isExecutionResult = (input: unknown): input is ExecutionResult => {
45
- if (typeof input !== 'object' || input === null) return false;
46
- const value = input as Record<string, unknown>;
47
- return 'data' in value || Array.isArray(value.errors);
48
- };
49
-
50
- export const handleResponseErrors = (result: ExecutionResult) => {
51
- if (result.errors?.length) {
52
- throw GQtyError.fromGraphQLErrors(result.errors);
53
- }
54
- };