@vrplatform/graphql 1.0.7 → 1.1.1
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/client/headers.d.ts +3 -0
- package/build/main/client/headers.js +42 -0
- package/build/main/client/index.d.ts +13 -0
- package/build/main/client/index.js +103 -0
- package/build/main/client/subscription.d.ts +3 -0
- package/build/main/client/subscription.js +29 -0
- package/build/main/common/account.d.ts +2 -0
- package/build/main/common/account.js +7 -0
- package/build/main/common/address.d.ts +9 -0
- package/build/main/common/address.js +2 -0
- package/build/main/common/bank-record.d.ts +2 -0
- package/build/main/common/bank-record.js +7 -0
- package/build/main/common/index.d.ts +5 -0
- package/build/main/common/index.js +21 -0
- package/build/main/common/listings.d.ts +4 -0
- package/build/main/common/listings.js +99 -0
- package/build/main/common/tenant.d.ts +19 -0
- package/build/main/common/tenant.js +85 -0
- package/build/main/error.d.ts +2 -0
- package/build/main/error.js +6 -0
- package/build/main/gqty/index.d.ts +7 -0
- package/build/main/gqty/index.js +48 -0
- package/build/main/gqty/schema.generated.d.ts +39211 -46819
- package/build/main/gqty/schema.generated.js +10382 -14191
- package/build/main/index.d.ts +4 -14
- package/build/main/index.js +7 -78
- package/build/main/tsconfig.main.tsbuildinfo +1 -1
- package/build/main/types.d.ts +5 -6
- package/build/main/wrap.d.ts +12 -0
- package/build/main/wrap.js +47 -0
- package/build/module/client/headers.d.ts +3 -0
- package/build/module/client/headers.js +39 -0
- package/build/module/client/index.d.ts +13 -0
- package/build/module/client/index.js +98 -0
- package/build/module/client/subscription.d.ts +3 -0
- package/build/module/client/subscription.js +26 -0
- package/build/module/common/account.d.ts +2 -0
- package/build/module/common/account.js +4 -0
- package/build/module/common/address.d.ts +9 -0
- package/build/module/common/address.js +1 -0
- package/build/module/common/bank-record.d.ts +2 -0
- package/build/module/common/bank-record.js +4 -0
- package/build/module/common/index.d.ts +5 -0
- package/build/module/common/index.js +5 -0
- package/build/module/common/listings.d.ts +4 -0
- package/build/module/common/listings.js +93 -0
- package/build/module/common/tenant.d.ts +19 -0
- package/build/module/common/tenant.js +77 -0
- package/build/module/error.d.ts +2 -0
- package/build/module/error.js +2 -0
- package/build/module/gqty/index.d.ts +7 -0
- package/build/module/gqty/index.js +41 -0
- package/build/module/gqty/schema.generated.d.ts +39211 -46819
- package/build/module/gqty/schema.generated.js +10382 -14191
- package/build/module/index.d.ts +4 -14
- package/build/module/index.js +4 -75
- package/build/module/tsconfig.esm.tsbuildinfo +1 -1
- package/build/module/types.d.ts +5 -6
- package/build/module/wrap.d.ts +12 -0
- package/build/module/wrap.js +44 -0
- package/package.json +25 -35
- package/src/client/headers.ts +51 -0
- package/src/client/index.ts +152 -0
- package/src/client/subscription.ts +34 -0
- package/src/common/account.ts +6 -0
- package/src/common/address.ts +9 -0
- package/src/common/bank-record.ts +6 -0
- package/src/common/index.ts +5 -0
- package/src/common/listings.ts +106 -0
- package/src/common/tenant.ts +101 -0
- package/src/error.ts +1 -0
- package/src/gqty/index.ts +62 -0
- package/src/gqty/schema.generated.d.ts +39211 -46819
- package/src/gqty/schema.generated.js +10421 -14218
- package/src/index.ts +9 -97
- package/src/types.ts +6 -10
- package/src/wrap.ts +67 -0
- package/LICENSE +0 -3
- package/build/main/create-client.d.ts +0 -6
- package/build/main/create-client.js +0 -107
- package/build/main/gqty/error.d.ts +0 -6
- package/build/main/gqty/error.js +0 -48
- package/build/module/create-client.d.ts +0 -6
- package/build/module/create-client.js +0 -104
- package/build/module/gqty/error.d.ts +0 -6
- package/build/module/gqty/error.js +0 -40
- package/src/create-client.ts +0 -120
- 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
|
-
};
|