@oanda/labs-order-book-widget 1.0.173 → 1.0.175
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/CHANGELOG.md +1372 -0
- package/dist/main/OrderBookWidget/ChartWithData.js +7 -6
- package/dist/main/OrderBookWidget/ChartWithData.js.map +1 -1
- package/dist/main/OrderBookWidget/Main.js +11 -11
- package/dist/main/OrderBookWidget/Main.js.map +1 -1
- package/dist/main/OrderBookWidget/OrderBookWidget.js +9 -9
- package/dist/main/OrderBookWidget/OrderBookWidget.js.map +1 -1
- package/dist/main/OrderBookWidget/components/Chart/Chart.js +14 -14
- package/dist/main/OrderBookWidget/components/Chart/Chart.js.map +1 -1
- package/dist/main/OrderBookWidget/components/Chart/formatters.js +3 -3
- package/dist/main/OrderBookWidget/components/Chart/formatters.js.map +1 -1
- package/dist/main/OrderBookWidget/components/Chart/getOption.js +10 -9
- package/dist/main/OrderBookWidget/components/Chart/getOption.js.map +1 -1
- package/dist/main/OrderBookWidget/components/Chart/types.js.map +1 -1
- package/dist/main/OrderBookWidget/config.js.map +1 -1
- package/dist/main/OrderBookWidget/render.js +9 -9
- package/dist/main/OrderBookWidget/render.js.map +1 -1
- package/dist/main/OrderBookWidget/types.js.map +1 -1
- package/dist/main/gql/getOrderPositionBooks.js +3 -18
- package/dist/main/gql/getOrderPositionBooks.js.map +1 -1
- package/dist/main/gql/types/fragment-masking.js +3 -2
- package/dist/main/gql/types/fragment-masking.js.map +1 -1
- package/dist/main/gql/types/gql.js +3 -2
- package/dist/main/gql/types/gql.js.map +1 -1
- package/dist/main/gql/types/graphql.js +114 -114
- package/dist/main/gql/types/graphql.js.map +1 -1
- package/dist/main/gql/types/index.js.map +1 -1
- package/dist/main/index.js +8 -8
- package/dist/main/index.js.map +1 -1
- package/dist/main/translations/index.js +1 -1
- package/dist/main/translations/index.js.map +1 -1
- package/dist/main/translations/translations.js.map +1 -1
- package/dist/module/OrderBookWidget/ChartWithData.js +7 -6
- package/dist/module/OrderBookWidget/ChartWithData.js.map +1 -1
- package/dist/module/OrderBookWidget/Main.js +10 -10
- package/dist/module/OrderBookWidget/Main.js.map +1 -1
- package/dist/module/OrderBookWidget/OrderBookWidget.js +9 -9
- package/dist/module/OrderBookWidget/OrderBookWidget.js.map +1 -1
- package/dist/module/OrderBookWidget/components/Chart/Chart.js +14 -14
- package/dist/module/OrderBookWidget/components/Chart/Chart.js.map +1 -1
- package/dist/module/OrderBookWidget/components/Chart/formatters.js +3 -3
- package/dist/module/OrderBookWidget/components/Chart/formatters.js.map +1 -1
- package/dist/module/OrderBookWidget/components/Chart/getOption.js +11 -10
- package/dist/module/OrderBookWidget/components/Chart/getOption.js.map +1 -1
- package/dist/module/OrderBookWidget/components/Chart/types.js.map +1 -1
- package/dist/module/OrderBookWidget/config.js +1 -1
- package/dist/module/OrderBookWidget/config.js.map +1 -1
- package/dist/module/OrderBookWidget/render.js +10 -10
- package/dist/module/OrderBookWidget/render.js.map +1 -1
- package/dist/module/OrderBookWidget/types.js.map +1 -1
- package/dist/module/gql/getOrderPositionBooks.js +3 -18
- package/dist/module/gql/getOrderPositionBooks.js.map +1 -1
- package/dist/module/gql/types/fragment-masking.js +3 -2
- package/dist/module/gql/types/fragment-masking.js.map +1 -1
- package/dist/module/gql/types/gql.js +3 -2
- package/dist/module/gql/types/gql.js.map +1 -1
- package/dist/module/gql/types/graphql.js +114 -114
- package/dist/module/gql/types/graphql.js.map +1 -1
- package/dist/module/gql/types/index.js +2 -2
- package/dist/module/gql/types/index.js.map +1 -1
- package/dist/module/index.js +1 -1
- package/dist/module/index.js.map +1 -1
- package/dist/module/translations/index.js +1 -1
- package/dist/module/translations/index.js.map +1 -1
- package/dist/module/translations/translations.js.map +1 -1
- package/dist/types/OrderBookWidget/ChartWithData.d.ts +2 -2
- package/dist/types/OrderBookWidget/Main.d.ts +1 -1
- package/dist/types/OrderBookWidget/OrderBookWidget.d.ts +1 -1
- package/dist/types/OrderBookWidget/components/Chart/Chart.d.ts +1 -1
- package/dist/types/OrderBookWidget/components/Chart/formatters.d.ts +1 -1
- package/dist/types/OrderBookWidget/components/Chart/getOption.d.ts +1 -1
- package/dist/types/OrderBookWidget/components/Chart/types.d.ts +2 -2
- package/dist/types/OrderBookWidget/config.d.ts +1 -1
- package/dist/types/OrderBookWidget/types.d.ts +2 -2
- package/dist/types/gql/types/gql.d.ts +2 -2
- package/dist/types/gql/types/index.d.ts +2 -2
- package/dist/types/index.d.ts +1 -1
- package/dist/types/translations/index.d.ts +2 -2
- package/package.json +3 -3
- package/src/OrderBookWidget/ChartWithData.tsx +40 -39
- package/src/OrderBookWidget/Main.tsx +48 -30
- package/src/OrderBookWidget/OrderBookWidget.tsx +8 -8
- package/src/OrderBookWidget/components/Chart/Chart.tsx +41 -29
- package/src/OrderBookWidget/components/Chart/formatters.ts +11 -4
- package/src/OrderBookWidget/components/Chart/getOption.ts +205 -188
- package/src/OrderBookWidget/components/Chart/types.ts +10 -13
- package/src/OrderBookWidget/config.ts +76 -53
- package/src/OrderBookWidget/render.tsx +81 -52
- package/src/OrderBookWidget/types.ts +3 -2
- package/src/gql/getOrderPositionBooks.ts +5 -1
- package/src/gql/types/fragment-masking.ts +41 -21
- package/src/gql/types/gql.ts +7 -3
- package/src/gql/types/graphql.ts +165 -44
- package/src/gql/types/index.ts +2 -2
- package/src/index.ts +1 -1
- package/src/translations/index.ts +4 -4
- package/src/translations/translations.ts +1 -3
- package/test/Main.test.tsx +12 -9
- package/test/chartOptions.test.ts +18 -12
|
@@ -1,67 +1,87 @@
|
|
|
1
1
|
import { BookType } from '../gql/types/graphql';
|
|
2
2
|
import { InstrumentId } from './types';
|
|
3
3
|
|
|
4
|
-
const navigationConfig = [
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
const navigationConfig = [
|
|
5
|
+
{
|
|
6
|
+
id: BookType.Order,
|
|
7
|
+
label: 'order_book',
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
id: BookType.Position,
|
|
11
|
+
label: 'position_book',
|
|
12
|
+
},
|
|
13
|
+
];
|
|
11
14
|
|
|
12
|
-
const instrumentSelectConfigOC = [
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
},
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
},
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
},
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
15
|
+
const instrumentSelectConfigOC = [
|
|
16
|
+
{
|
|
17
|
+
id: InstrumentId.EUR_AUD,
|
|
18
|
+
label: 'EUR/AUD',
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
id: InstrumentId.EUR_GBP,
|
|
22
|
+
label: 'EUR/GBP',
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
id: InstrumentId.EUR_JPY,
|
|
26
|
+
label: 'EUR/JPY',
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
id: InstrumentId.EUR_USD,
|
|
30
|
+
label: 'EUR/USD',
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
id: InstrumentId.EUR_CHF,
|
|
34
|
+
label: 'EUR/CHF',
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
id: InstrumentId.USD_CHF,
|
|
38
|
+
label: 'USD/CHF',
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
id: InstrumentId.USD_JPY,
|
|
42
|
+
label: 'USD/JPY',
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
id: InstrumentId.USD_CAD,
|
|
46
|
+
label: 'USD/CAD',
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
id: InstrumentId.GBP_USD,
|
|
50
|
+
label: 'GBP/USD',
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
id: InstrumentId.GBP_JPY,
|
|
54
|
+
label: 'GBP/JPY',
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
id: InstrumentId.GBP_CHF,
|
|
58
|
+
label: 'GBP/CHF',
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
id: InstrumentId.AUD_JPY,
|
|
62
|
+
label: 'AUD/JPY',
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
id: InstrumentId.AUD_USD,
|
|
66
|
+
label: 'AUD/USD',
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
id: InstrumentId.NZD_USD,
|
|
70
|
+
label: 'NZD/USD',
|
|
71
|
+
},
|
|
72
|
+
];
|
|
55
73
|
|
|
56
74
|
const instrumentSelectConfig = [
|
|
57
75
|
...instrumentSelectConfigOC,
|
|
58
76
|
{
|
|
59
77
|
id: InstrumentId.XAU_USD,
|
|
60
78
|
label: 'XAU/USD',
|
|
61
|
-
},
|
|
79
|
+
},
|
|
80
|
+
{
|
|
62
81
|
id: InstrumentId.XAG_USD,
|
|
63
82
|
label: 'XAG/USD',
|
|
64
|
-
}
|
|
83
|
+
},
|
|
84
|
+
];
|
|
65
85
|
|
|
66
86
|
const instrumentPrecisionConfig: Record<InstrumentId, number> = {
|
|
67
87
|
[InstrumentId.EUR_AUD]: 5,
|
|
@@ -82,5 +102,8 @@ const instrumentPrecisionConfig: Record<InstrumentId, number> = {
|
|
|
82
102
|
[InstrumentId.XAG_USD]: 5,
|
|
83
103
|
};
|
|
84
104
|
export {
|
|
85
|
-
|
|
105
|
+
instrumentPrecisionConfig,
|
|
106
|
+
instrumentSelectConfig,
|
|
107
|
+
instrumentSelectConfigOC,
|
|
108
|
+
navigationConfig,
|
|
86
109
|
};
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
import type { Theme } from '@oanda/labs-widget-common';
|
|
2
|
+
import { validateLocale, validateToolParams } from '@oanda/labs-widget-common';
|
|
1
3
|
import React from 'react';
|
|
2
4
|
import { createRoot } from 'react-dom/client';
|
|
3
|
-
|
|
4
|
-
import { OrderBookWidget } from './OrderBookWidget';
|
|
5
|
+
|
|
5
6
|
import { Division } from '../gql/types/graphql';
|
|
6
|
-
import {
|
|
7
|
+
import { instrumentSelectConfig, instrumentSelectConfigOC } from './config';
|
|
8
|
+
import { OrderBookWidget } from './OrderBookWidget';
|
|
9
|
+
import type { InstrumentId } from './types';
|
|
7
10
|
|
|
8
11
|
const {
|
|
9
12
|
graphqlUrl: configGraphQl,
|
|
@@ -13,79 +16,105 @@ const {
|
|
|
13
16
|
division: configDivision,
|
|
14
17
|
} = window.volatilityChartWidgetConfig || {};
|
|
15
18
|
|
|
16
|
-
const {
|
|
17
|
-
graphqlUrl,
|
|
18
|
-
} = window.widgetsConfig || {};
|
|
19
|
+
const { graphqlUrl } = window.widgetsConfig || {};
|
|
19
20
|
|
|
20
|
-
const orderBookElements = document.querySelectorAll(
|
|
21
|
+
const orderBookElements = document.querySelectorAll(
|
|
22
|
+
'div[data-order-book-params]'
|
|
23
|
+
);
|
|
21
24
|
|
|
22
25
|
if (orderBookElements.length > 0) {
|
|
23
26
|
orderBookElements.forEach((element) => {
|
|
24
27
|
const root = createRoot(element);
|
|
25
28
|
const params = element.getAttribute('data-order-book-params');
|
|
26
29
|
const mode = element.getAttribute('data-mode');
|
|
27
|
-
const {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
+
const { instrument, locale, division, logoLink } = JSON.parse(
|
|
31
|
+
params as string
|
|
32
|
+
);
|
|
30
33
|
|
|
31
|
-
const isParamError = instrument
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
34
|
+
const isParamError = instrument
|
|
35
|
+
? validateToolParams(
|
|
36
|
+
{
|
|
37
|
+
locale,
|
|
38
|
+
graphqlUrl,
|
|
39
|
+
division,
|
|
40
|
+
instrument,
|
|
41
|
+
},
|
|
42
|
+
[
|
|
43
|
+
{
|
|
44
|
+
name: 'locale',
|
|
45
|
+
valueCheck: (value: string | undefined) => validateLocale(value),
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
name: 'graphqlUrl',
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
name: 'division',
|
|
52
|
+
valueCheck: (value: Division) =>
|
|
53
|
+
Object.values(Division).includes(value),
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
name: 'instrument',
|
|
57
|
+
valueCheck: (value) => {
|
|
58
|
+
const acceptableInstruments =
|
|
59
|
+
division === Division.Oc
|
|
60
|
+
? instrumentSelectConfigOC
|
|
61
|
+
: instrumentSelectConfig;
|
|
48
62
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
63
|
+
return Object.values(
|
|
64
|
+
acceptableInstruments.map((x) => x.id)
|
|
65
|
+
).includes(value.replace(/\/|_/g, '') as InstrumentId);
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
]
|
|
69
|
+
)
|
|
70
|
+
: validateToolParams(
|
|
71
|
+
{
|
|
72
|
+
locale,
|
|
73
|
+
graphqlUrl,
|
|
74
|
+
division,
|
|
75
|
+
logoLink,
|
|
76
|
+
},
|
|
77
|
+
[
|
|
78
|
+
{
|
|
79
|
+
name: 'locale',
|
|
80
|
+
valueCheck: (value: string | undefined) => validateLocale(value),
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
name: 'graphqlUrl',
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
name: 'division',
|
|
87
|
+
valueCheck: (value: Division) =>
|
|
88
|
+
Object.values(Division).includes(value),
|
|
89
|
+
},
|
|
90
|
+
]
|
|
91
|
+
);
|
|
66
92
|
|
|
67
93
|
root.render(
|
|
68
94
|
<OrderBookWidget
|
|
69
|
-
|
|
95
|
+
division={division}
|
|
70
96
|
graphqlUrl={graphqlUrl}
|
|
71
97
|
instrument={instrument}
|
|
72
|
-
theme={mode as Theme}
|
|
73
98
|
isParamError={isParamError}
|
|
74
|
-
|
|
99
|
+
locale={locale}
|
|
75
100
|
logoLink={logoLink}
|
|
76
|
-
|
|
101
|
+
theme={mode as Theme}
|
|
102
|
+
/>
|
|
77
103
|
);
|
|
78
104
|
});
|
|
79
105
|
} else {
|
|
80
|
-
const container = document.
|
|
106
|
+
const container: HTMLElement | null = document.querySelector(
|
|
107
|
+
configRenderElementId
|
|
108
|
+
);
|
|
109
|
+
|
|
81
110
|
const root = createRoot(container!);
|
|
82
111
|
|
|
83
112
|
root.render(
|
|
84
113
|
<OrderBookWidget
|
|
85
|
-
|
|
114
|
+
division={configDivision}
|
|
86
115
|
graphqlUrl={configGraphQl}
|
|
87
116
|
instrument={configInstrument}
|
|
88
|
-
|
|
89
|
-
|
|
117
|
+
locale={configLocale}
|
|
118
|
+
/>
|
|
90
119
|
);
|
|
91
120
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { WidgetConfig } from '@oanda/labs-widget-common';
|
|
2
|
-
|
|
1
|
+
import type { WidgetConfig } from '@oanda/labs-widget-common';
|
|
2
|
+
|
|
3
|
+
import type { BookType, Division } from '../gql/types/graphql';
|
|
3
4
|
|
|
4
5
|
export interface OrderBookWidgetConfig extends WidgetConfig {
|
|
5
6
|
instrument: InstrumentId;
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { gql } from '@apollo/client';
|
|
2
2
|
|
|
3
3
|
const getOrderPositionBooks = gql`
|
|
4
|
-
query GetOrderPositionBooks(
|
|
4
|
+
query GetOrderPositionBooks(
|
|
5
|
+
$instrument: String!
|
|
6
|
+
$bookType: BookType!
|
|
7
|
+
$recentHours: Int
|
|
8
|
+
) {
|
|
5
9
|
orderPositionBooks(
|
|
6
10
|
instrument: $instrument
|
|
7
11
|
bookType: $bookType
|
|
@@ -1,18 +1,21 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
ResultOf,
|
|
3
|
+
DocumentTypeDecoration,
|
|
4
|
+
TypedDocumentNode,
|
|
5
|
+
} from '@graphql-typed-document-node/core';
|
|
2
6
|
import { FragmentDefinitionNode } from 'graphql';
|
|
3
7
|
import { Incremental } from './graphql';
|
|
4
8
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
any
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
export type FragmentType<
|
|
10
|
+
TDocumentType extends DocumentTypeDecoration<any, any>,
|
|
11
|
+
> =
|
|
12
|
+
TDocumentType extends DocumentTypeDecoration<infer TType, any>
|
|
13
|
+
? [TType] extends [{ ' $fragmentName'?: infer TKey }]
|
|
14
|
+
? TKey extends string
|
|
15
|
+
? { ' $fragmentRefs'?: { [key in TKey]: TType } }
|
|
16
|
+
: never
|
|
13
17
|
: never
|
|
14
|
-
: never
|
|
15
|
-
: never;
|
|
18
|
+
: never;
|
|
16
19
|
|
|
17
20
|
// return non-nullable if `fragmentType` is non-nullable
|
|
18
21
|
export function useFragment<TType>(
|
|
@@ -22,7 +25,10 @@ export function useFragment<TType>(
|
|
|
22
25
|
// return nullable if `fragmentType` is nullable
|
|
23
26
|
export function useFragment<TType>(
|
|
24
27
|
_documentNode: DocumentTypeDecoration<TType, any>,
|
|
25
|
-
fragmentType:
|
|
28
|
+
fragmentType:
|
|
29
|
+
| FragmentType<DocumentTypeDecoration<TType, any>>
|
|
30
|
+
| null
|
|
31
|
+
| undefined
|
|
26
32
|
): TType | null | undefined;
|
|
27
33
|
// return array of non-nullable if `fragmentType` is array of non-nullable
|
|
28
34
|
export function useFragment<TType>(
|
|
@@ -32,35 +38,49 @@ export function useFragment<TType>(
|
|
|
32
38
|
// return array of nullable if `fragmentType` is array of nullable
|
|
33
39
|
export function useFragment<TType>(
|
|
34
40
|
_documentNode: DocumentTypeDecoration<TType, any>,
|
|
35
|
-
fragmentType:
|
|
41
|
+
fragmentType:
|
|
42
|
+
| ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>>>
|
|
43
|
+
| null
|
|
44
|
+
| undefined
|
|
36
45
|
): ReadonlyArray<TType> | null | undefined;
|
|
37
46
|
export function useFragment<TType>(
|
|
38
47
|
_documentNode: DocumentTypeDecoration<TType, any>,
|
|
39
|
-
fragmentType:
|
|
48
|
+
fragmentType:
|
|
49
|
+
| FragmentType<DocumentTypeDecoration<TType, any>>
|
|
50
|
+
| ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>>>
|
|
51
|
+
| null
|
|
52
|
+
| undefined
|
|
40
53
|
): TType | ReadonlyArray<TType> | null | undefined {
|
|
41
54
|
return fragmentType as any;
|
|
42
55
|
}
|
|
43
56
|
|
|
44
|
-
|
|
45
57
|
export function makeFragmentData<
|
|
46
58
|
F extends DocumentTypeDecoration<any, any>,
|
|
47
|
-
FT extends ResultOf<F
|
|
59
|
+
FT extends ResultOf<F>,
|
|
48
60
|
>(data: FT, _fragment: F): FragmentType<F> {
|
|
49
61
|
return data as FragmentType<F>;
|
|
50
62
|
}
|
|
51
63
|
export function isFragmentReady<TQuery, TFrag>(
|
|
52
64
|
queryNode: DocumentTypeDecoration<TQuery, any>,
|
|
53
65
|
fragmentNode: TypedDocumentNode<TFrag>,
|
|
54
|
-
data:
|
|
66
|
+
data:
|
|
67
|
+
| FragmentType<TypedDocumentNode<Incremental<TFrag>, any>>
|
|
68
|
+
| null
|
|
69
|
+
| undefined
|
|
55
70
|
): data is FragmentType<typeof fragmentNode> {
|
|
56
|
-
const deferredFields = (
|
|
57
|
-
|
|
71
|
+
const deferredFields = (
|
|
72
|
+
queryNode as {
|
|
73
|
+
__meta__?: { deferredFields: Record<string, (keyof TFrag)[]> };
|
|
74
|
+
}
|
|
75
|
+
).__meta__?.deferredFields;
|
|
58
76
|
|
|
59
77
|
if (!deferredFields) return true;
|
|
60
78
|
|
|
61
|
-
const fragDef = fragmentNode.definitions[0] as
|
|
79
|
+
const fragDef = fragmentNode.definitions[0] as
|
|
80
|
+
| FragmentDefinitionNode
|
|
81
|
+
| undefined;
|
|
62
82
|
const fragName = fragDef?.name?.value;
|
|
63
83
|
|
|
64
84
|
const fields = (fragName && deferredFields[fragName]) || [];
|
|
65
|
-
return fields.length > 0 && fields.every(field => data && field in data);
|
|
85
|
+
return fields.length > 0 && fields.every((field) => data && field in data);
|
|
66
86
|
}
|
package/src/gql/types/gql.ts
CHANGED
|
@@ -13,7 +13,8 @@ import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/
|
|
|
13
13
|
* Therefore it is highly recommended to use the babel or swc plugin for production.
|
|
14
14
|
*/
|
|
15
15
|
const documents = {
|
|
16
|
-
|
|
16
|
+
'\n query GetOrderPositionBooks($instrument: String!, $bookType: BookType!, $recentHours: Int) {\n orderPositionBooks(\n instrument: $instrument\n bookType: $bookType\n recentHours: $recentHours\n ) {\n bucketWidth\n price\n time\n buckets {\n price\n longCountPercent\n shortCountPercent\n }\n }\n }\n':
|
|
17
|
+
types.GetOrderPositionBooksDocument,
|
|
17
18
|
};
|
|
18
19
|
|
|
19
20
|
/**
|
|
@@ -33,10 +34,13 @@ export function graphql(source: string): unknown;
|
|
|
33
34
|
/**
|
|
34
35
|
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
|
|
35
36
|
*/
|
|
36
|
-
export function graphql(
|
|
37
|
+
export function graphql(
|
|
38
|
+
source: '\n query GetOrderPositionBooks($instrument: String!, $bookType: BookType!, $recentHours: Int) {\n orderPositionBooks(\n instrument: $instrument\n bookType: $bookType\n recentHours: $recentHours\n ) {\n bucketWidth\n price\n time\n buckets {\n price\n longCountPercent\n shortCountPercent\n }\n }\n }\n'
|
|
39
|
+
): (typeof documents)['\n query GetOrderPositionBooks($instrument: String!, $bookType: BookType!, $recentHours: Int) {\n orderPositionBooks(\n instrument: $instrument\n bookType: $bookType\n recentHours: $recentHours\n ) {\n bucketWidth\n price\n time\n buckets {\n price\n longCountPercent\n shortCountPercent\n }\n }\n }\n'];
|
|
37
40
|
|
|
38
41
|
export function graphql(source: string) {
|
|
39
42
|
return (documents as any)[source] ?? {};
|
|
40
43
|
}
|
|
41
44
|
|
|
42
|
-
export type DocumentType<TDocumentNode extends DocumentNode<any, any>> =
|
|
45
|
+
export type DocumentType<TDocumentNode extends DocumentNode<any, any>> =
|
|
46
|
+
TDocumentNode extends DocumentNode<infer TType, any> ? TType : never;
|