@oanda/labs-sentiment-widget 1.0.172 → 1.0.174
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 +1364 -0
- package/dist/main/SentimentWidget/SentimentWidget.js +18 -23
- package/dist/main/SentimentWidget/SentimentWidget.js.map +1 -1
- package/dist/main/SentimentWidget/Tool.js +18 -18
- package/dist/main/SentimentWidget/Tool.js.map +1 -1
- package/dist/main/SentimentWidget/Widget.js +15 -17
- package/dist/main/SentimentWidget/Widget.js.map +1 -1
- package/dist/main/SentimentWidget/components/SortSwitch/SortSwitch.js +14 -16
- package/dist/main/SentimentWidget/components/SortSwitch/SortSwitch.js.map +1 -1
- package/dist/main/SentimentWidget/render.js +9 -9
- package/dist/main/SentimentWidget/render.js.map +1 -1
- package/dist/main/SentimentWidget/types.js.map +1 -1
- package/dist/main/SentimentWidget/utils.js.map +1 -1
- package/dist/main/gql/getInstrumentSentiment.js +2 -8
- package/dist/main/gql/getInstrumentSentiment.js.map +1 -1
- package/dist/main/gql/getSentimentList.js +2 -6
- package/dist/main/gql/getSentimentList.js.map +1 -1
- package/dist/main/gql/types/fragment-masking.js.map +1 -1
- package/dist/main/gql/types/gql.js +2 -2
- package/dist/main/gql/types/gql.js.map +1 -1
- package/dist/main/gql/types/graphql.js +154 -154
- 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/SentimentWidget/SentimentWidget.js +19 -24
- package/dist/module/SentimentWidget/SentimentWidget.js.map +1 -1
- package/dist/module/SentimentWidget/Tool.js +17 -17
- package/dist/module/SentimentWidget/Tool.js.map +1 -1
- package/dist/module/SentimentWidget/Widget.js +16 -16
- package/dist/module/SentimentWidget/Widget.js.map +1 -1
- package/dist/module/SentimentWidget/components/SortSwitch/SortSwitch.js +14 -14
- package/dist/module/SentimentWidget/components/SortSwitch/SortSwitch.js.map +1 -1
- package/dist/module/SentimentWidget/render.js +9 -9
- package/dist/module/SentimentWidget/render.js.map +1 -1
- package/dist/module/SentimentWidget/types.js.map +1 -1
- package/dist/module/SentimentWidget/utils.js.map +1 -1
- package/dist/module/gql/getInstrumentSentiment.js +2 -8
- package/dist/module/gql/getInstrumentSentiment.js.map +1 -1
- package/dist/module/gql/getSentimentList.js +2 -6
- package/dist/module/gql/getSentimentList.js.map +1 -1
- package/dist/module/gql/types/fragment-masking.js.map +1 -1
- package/dist/module/gql/types/gql.js +2 -2
- package/dist/module/gql/types/gql.js.map +1 -1
- package/dist/module/gql/types/graphql.js +154 -154
- 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/SentimentWidget/SentimentWidget.d.ts +1 -1
- package/dist/types/SentimentWidget/Tool.d.ts +1 -1
- package/dist/types/SentimentWidget/Widget.d.ts +1 -1
- package/dist/types/SentimentWidget/components/SortSwitch/SortSwitch.d.ts +2 -2
- package/dist/types/SentimentWidget/types.d.ts +2 -2
- package/dist/types/SentimentWidget/utils.d.ts +2 -1
- package/dist/types/gql/types/gql.d.ts +4 -4
- 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/SentimentWidget/SentimentWidget.tsx +28 -33
- package/src/SentimentWidget/Tool.tsx +96 -80
- package/src/SentimentWidget/Widget.tsx +72 -66
- package/src/SentimentWidget/components/SortSwitch/SortSwitch.tsx +42 -39
- package/src/SentimentWidget/render.tsx +40 -28
- package/src/SentimentWidget/types.ts +3 -2
- package/src/SentimentWidget/utils.ts +12 -4
- package/src/gql/getInstrumentSentiment.ts +2 -8
- package/src/gql/getSentimentList.ts +2 -6
- package/src/gql/types/fragment-masking.ts +41 -21
- package/src/gql/types/gql.ts +12 -5
- package/src/gql/types/graphql.ts +225 -47
- 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 +2 -1
- package/test/SortSwitch.test.tsx +36 -23
- package/test/Tool.test.tsx +13 -11
- package/test/Widget.test.tsx +31 -26
- package/test/sortData.test.ts +49 -13
|
@@ -1,79 +1,82 @@
|
|
|
1
|
-
import React, { useContext } from 'react';
|
|
2
|
-
import classnames from 'classnames';
|
|
3
1
|
import {
|
|
4
|
-
|
|
2
|
+
LongArrowDown,
|
|
3
|
+
LongArrowUp,
|
|
4
|
+
useLayoutProvider,
|
|
5
5
|
} from '@oanda/labs-widget-common';
|
|
6
|
-
import
|
|
6
|
+
import classnames from 'classnames';
|
|
7
|
+
import React from 'react';
|
|
8
|
+
|
|
9
|
+
import type { SortSwitchProps } from './types';
|
|
10
|
+
import { SelectedArrow } from './types';
|
|
7
11
|
|
|
8
12
|
const SortSwitch = ({
|
|
9
|
-
onClickButtonDown,
|
|
13
|
+
onClickButtonDown,
|
|
14
|
+
onClickButtonUp,
|
|
15
|
+
selected,
|
|
16
|
+
disabled,
|
|
10
17
|
}: SortSwitchProps) => {
|
|
11
|
-
const { isDark } =
|
|
18
|
+
const { isDark } = useLayoutProvider();
|
|
12
19
|
|
|
13
20
|
return (
|
|
14
21
|
<div
|
|
15
|
-
data-testid="sort-switch"
|
|
16
22
|
className={classnames(
|
|
17
23
|
'lw-flex lw-rounded lw-border-[1px] lw-border-solid lw-font-sans lw-text-xs lw-tracking-normal',
|
|
18
24
|
{
|
|
19
25
|
'lw-border-border-disabled': disabled,
|
|
20
26
|
'lw-border-secondary': !disabled,
|
|
21
|
-
}
|
|
27
|
+
}
|
|
22
28
|
)}
|
|
29
|
+
data-testid="sort-switch"
|
|
23
30
|
>
|
|
24
31
|
<button
|
|
25
|
-
data-testid="sort-switch-button-up"
|
|
26
|
-
disabled={disabled || selected === SelectedArrow.UP}
|
|
27
|
-
type="button"
|
|
28
|
-
onClick={onClickButtonUp}
|
|
29
32
|
className={classnames(
|
|
30
33
|
'lw-flex lw-h-11 lw-w-11 lw-grow-0 lw-items-center lw-justify-center lw-border-solid focus:lw-outline-secondary [&:enabled:hover>*]:-lw-translate-y-1',
|
|
31
34
|
{
|
|
32
35
|
'lw-border-r-[1px] lw-border-r-border-disabled': disabled,
|
|
33
36
|
'lw-bg-secondary': selected === SelectedArrow.UP && !disabled,
|
|
34
|
-
}
|
|
37
|
+
}
|
|
35
38
|
)}
|
|
39
|
+
data-testid="sort-switch-button-up"
|
|
40
|
+
disabled={disabled || selected === SelectedArrow.UP}
|
|
41
|
+
type="button"
|
|
42
|
+
onClick={onClickButtonUp}
|
|
36
43
|
>
|
|
37
44
|
<LongArrowUp
|
|
38
|
-
className={classnames(
|
|
39
|
-
'lw-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
)}
|
|
45
|
+
className={classnames('lw-transition-transform', {
|
|
46
|
+
'lw-stroke-border-disabled': disabled,
|
|
47
|
+
'lw-stroke-secondary': selected !== SelectedArrow.UP && !disabled,
|
|
48
|
+
'lw-stroke-bg-primary':
|
|
49
|
+
selected === SelectedArrow.UP && !disabled && isDark,
|
|
50
|
+
'lw-stroke-ok':
|
|
51
|
+
selected === SelectedArrow.UP && !disabled && !isDark,
|
|
52
|
+
})}
|
|
47
53
|
/>
|
|
48
54
|
</button>
|
|
49
55
|
<button
|
|
50
|
-
data-testid="sort-switch-button-down"
|
|
51
|
-
disabled={disabled || selected === SelectedArrow.DOWN}
|
|
52
|
-
type="button"
|
|
53
|
-
onClick={onClickButtonDown}
|
|
54
56
|
className={classnames(
|
|
55
57
|
'lw-flex lw-h-11 lw-w-11 lw-grow-0 lw-items-center lw-justify-center lw-text-center focus:lw-outline-secondary [&:enabled:hover>*]:lw-translate-y-1',
|
|
56
58
|
{
|
|
57
59
|
'lw-bg-secondary': selected === SelectedArrow.DOWN && !disabled,
|
|
58
|
-
}
|
|
60
|
+
}
|
|
59
61
|
)}
|
|
62
|
+
data-testid="sort-switch-button-down"
|
|
63
|
+
disabled={disabled || selected === SelectedArrow.DOWN}
|
|
64
|
+
type="button"
|
|
65
|
+
onClick={onClickButtonDown}
|
|
60
66
|
>
|
|
61
67
|
<LongArrowDown
|
|
62
|
-
className={classnames(
|
|
63
|
-
'lw-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
)}
|
|
68
|
+
className={classnames('lw-transition-transform', {
|
|
69
|
+
'lw-stroke-border-disabled': disabled,
|
|
70
|
+
'lw-stroke-secondary': selected !== SelectedArrow.DOWN && !disabled,
|
|
71
|
+
'lw-stroke-bg-primary':
|
|
72
|
+
selected === SelectedArrow.DOWN && !disabled && isDark,
|
|
73
|
+
'lw-stroke-ok':
|
|
74
|
+
selected === SelectedArrow.DOWN && !disabled && !isDark,
|
|
75
|
+
})}
|
|
71
76
|
/>
|
|
72
77
|
</button>
|
|
73
78
|
</div>
|
|
74
79
|
);
|
|
75
80
|
};
|
|
76
81
|
|
|
77
|
-
export {
|
|
78
|
-
SortSwitch,
|
|
79
|
-
};
|
|
82
|
+
export { SortSwitch };
|
|
@@ -1,8 +1,10 @@
|
|
|
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 { SentimentWidget } from './SentimentWidget';
|
|
5
|
+
|
|
5
6
|
import { Division } from '../gql/types/graphql';
|
|
7
|
+
import { SentimentWidget } from './SentimentWidget';
|
|
6
8
|
|
|
7
9
|
const {
|
|
8
10
|
graphqlUrl: configGraphQl,
|
|
@@ -12,56 +14,66 @@ const {
|
|
|
12
14
|
locale: configLocale,
|
|
13
15
|
} = window.sentimentWidgetConfig || {};
|
|
14
16
|
|
|
15
|
-
const {
|
|
16
|
-
graphqlUrl,
|
|
17
|
-
} = window.widgetsConfig || {};
|
|
17
|
+
const { graphqlUrl } = window.widgetsConfig || {};
|
|
18
18
|
|
|
19
|
-
const sentimentParamsElements = document.querySelectorAll(
|
|
19
|
+
const sentimentParamsElements = document.querySelectorAll(
|
|
20
|
+
'div[data-sentiment-params]'
|
|
21
|
+
);
|
|
20
22
|
|
|
21
23
|
if (sentimentParamsElements.length > 0) {
|
|
22
24
|
sentimentParamsElements.forEach((element) => {
|
|
23
25
|
const root = createRoot(element);
|
|
24
26
|
const params = element.getAttribute('data-sentiment-params');
|
|
25
27
|
const mode = element.getAttribute('data-mode');
|
|
26
|
-
const {
|
|
27
|
-
|
|
28
|
-
} = JSON.parse(params as string);
|
|
28
|
+
const { instrument, division, locale, includeDescriptionLabels, logoLink } =
|
|
29
|
+
JSON.parse(params as string);
|
|
29
30
|
|
|
30
|
-
const isParamError = validateToolParams(
|
|
31
|
-
division, locale, graphqlUrl,
|
|
32
|
-
}, [
|
|
31
|
+
const isParamError = validateToolParams(
|
|
33
32
|
{
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
name: 'division',
|
|
38
|
-
valueCheck: (value) => Object.values(Division).includes(value),
|
|
39
|
-
}, {
|
|
40
|
-
name: 'graphqlUrl',
|
|
33
|
+
division,
|
|
34
|
+
locale,
|
|
35
|
+
graphqlUrl,
|
|
41
36
|
},
|
|
42
|
-
|
|
37
|
+
[
|
|
38
|
+
{
|
|
39
|
+
name: 'locale',
|
|
40
|
+
valueCheck: (value: string | undefined) => validateLocale(value),
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: 'division',
|
|
44
|
+
valueCheck: (value: Division) =>
|
|
45
|
+
Object.values(Division).includes(value),
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
name: 'graphqlUrl',
|
|
49
|
+
},
|
|
50
|
+
]
|
|
51
|
+
);
|
|
43
52
|
root.render(
|
|
44
53
|
<SentimentWidget
|
|
45
|
-
graphqlUrl={graphqlUrl}
|
|
46
54
|
division={division}
|
|
47
|
-
|
|
48
|
-
locale={locale}
|
|
49
|
-
theme={mode as Theme}
|
|
55
|
+
graphqlUrl={graphqlUrl}
|
|
50
56
|
includeDescriptionLabels={includeDescriptionLabels}
|
|
57
|
+
instrument={instrument}
|
|
51
58
|
isParamError={isParamError}
|
|
59
|
+
locale={locale}
|
|
52
60
|
logoLink={logoLink}
|
|
53
|
-
|
|
61
|
+
theme={mode as Theme}
|
|
62
|
+
/>
|
|
54
63
|
);
|
|
55
64
|
});
|
|
56
65
|
} else {
|
|
57
|
-
const container = document.
|
|
66
|
+
const container: HTMLElement | null = document.querySelector(
|
|
67
|
+
configRenderElementId
|
|
68
|
+
);
|
|
69
|
+
|
|
58
70
|
const root = createRoot(container!);
|
|
59
71
|
root.render(
|
|
60
72
|
<SentimentWidget
|
|
61
|
-
graphqlUrl={configGraphQl}
|
|
62
73
|
division={configDivision}
|
|
74
|
+
graphqlUrl={configGraphQl}
|
|
63
75
|
instrument={configInstrument}
|
|
64
76
|
locale={configLocale}
|
|
65
|
-
|
|
77
|
+
/>
|
|
66
78
|
);
|
|
67
79
|
}
|
|
@@ -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 { Division } from '../gql/types/graphql';
|
|
3
4
|
|
|
4
5
|
export interface SentimentConfig extends WidgetConfig {
|
|
5
6
|
division: Division;
|
|
@@ -1,12 +1,20 @@
|
|
|
1
|
-
import { GetSentimentListQuery
|
|
1
|
+
import type { GetSentimentListQuery } from '../gql/types/graphql';
|
|
2
|
+
import { Sort } from '../gql/types/graphql';
|
|
2
3
|
|
|
3
|
-
export const sortData = (
|
|
4
|
+
export const sortData = (
|
|
5
|
+
{ sentimentList }: GetSentimentListQuery,
|
|
6
|
+
sort: Sort
|
|
7
|
+
) => {
|
|
4
8
|
if (!sentimentList) {
|
|
5
9
|
return [];
|
|
6
10
|
}
|
|
7
11
|
|
|
8
12
|
if (sort === Sort.Bullish) {
|
|
9
|
-
return [...sentimentList].sort(
|
|
13
|
+
return [...sentimentList].sort(
|
|
14
|
+
(a, b) => a.sentiment.shortPercent - b.sentiment.shortPercent
|
|
15
|
+
);
|
|
10
16
|
}
|
|
11
|
-
return [...sentimentList].sort(
|
|
17
|
+
return [...sentimentList].sort(
|
|
18
|
+
(a, b) => a.sentiment.longPercent - b.sentiment.longPercent
|
|
19
|
+
);
|
|
12
20
|
};
|
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
import { gql } from '@apollo/client';
|
|
2
2
|
|
|
3
3
|
const getInstrumentSentiment = gql`
|
|
4
|
-
query GetInstrumentSentiment(
|
|
5
|
-
$name:
|
|
6
|
-
$division: Division
|
|
7
|
-
) {
|
|
8
|
-
sentiment(
|
|
9
|
-
name: $name
|
|
10
|
-
division: $division
|
|
11
|
-
) {
|
|
4
|
+
query GetInstrumentSentiment($name: String!, $division: Division) {
|
|
5
|
+
sentiment(name: $name, division: $division) {
|
|
12
6
|
name
|
|
13
7
|
displayName
|
|
14
8
|
sentiment {
|
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
import { gql } from '@apollo/client';
|
|
2
2
|
|
|
3
3
|
const getSentimentList = gql`
|
|
4
|
-
query GetSentimentList
|
|
5
|
-
|
|
6
|
-
) {
|
|
7
|
-
sentimentList (
|
|
8
|
-
division: $division
|
|
9
|
-
) {
|
|
4
|
+
query GetSentimentList($division: Division) {
|
|
5
|
+
sentimentList(division: $division) {
|
|
10
6
|
name
|
|
11
7
|
displayName
|
|
12
8
|
sentiment {
|
|
@@ -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,8 +13,10 @@ 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
|
-
|
|
17
|
-
|
|
16
|
+
'\n query GetInstrumentSentiment(\n $name: String!\n $division: Division\n ) {\n sentiment(\n name: $name\n division: $division\n ) {\n name\n displayName\n sentiment {\n shortPercent\n longPercent\n }\n updatedAt\n }\n }\n':
|
|
17
|
+
types.GetInstrumentSentimentDocument,
|
|
18
|
+
'\n query GetSentimentList (\n $division: Division\n ) {\n sentimentList (\n division: $division\n ) {\n name\n displayName\n sentiment {\n shortPercent\n longPercent\n }\n updatedAt\n }\n }\n':
|
|
19
|
+
types.GetSentimentListDocument,
|
|
18
20
|
};
|
|
19
21
|
|
|
20
22
|
/**
|
|
@@ -34,14 +36,19 @@ export function graphql(source: string): unknown;
|
|
|
34
36
|
/**
|
|
35
37
|
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
|
|
36
38
|
*/
|
|
37
|
-
export function graphql(
|
|
39
|
+
export function graphql(
|
|
40
|
+
source: '\n query GetInstrumentSentiment(\n $name: String!\n $division: Division\n ) {\n sentiment(\n name: $name\n division: $division\n ) {\n name\n displayName\n sentiment {\n shortPercent\n longPercent\n }\n updatedAt\n }\n }\n'
|
|
41
|
+
): (typeof documents)['\n query GetInstrumentSentiment(\n $name: String!\n $division: Division\n ) {\n sentiment(\n name: $name\n division: $division\n ) {\n name\n displayName\n sentiment {\n shortPercent\n longPercent\n }\n updatedAt\n }\n }\n'];
|
|
38
42
|
/**
|
|
39
43
|
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
|
|
40
44
|
*/
|
|
41
|
-
export function graphql(
|
|
45
|
+
export function graphql(
|
|
46
|
+
source: '\n query GetSentimentList (\n $division: Division\n ) {\n sentimentList (\n division: $division\n ) {\n name\n displayName\n sentiment {\n shortPercent\n longPercent\n }\n updatedAt\n }\n }\n'
|
|
47
|
+
): (typeof documents)['\n query GetSentimentList (\n $division: Division\n ) {\n sentimentList (\n division: $division\n ) {\n name\n displayName\n sentiment {\n shortPercent\n longPercent\n }\n updatedAt\n }\n }\n'];
|
|
42
48
|
|
|
43
49
|
export function graphql(source: string) {
|
|
44
50
|
return (documents as any)[source] ?? {};
|
|
45
51
|
}
|
|
46
52
|
|
|
47
|
-
export type DocumentType<TDocumentNode extends DocumentNode<any, any>> =
|
|
53
|
+
export type DocumentType<TDocumentNode extends DocumentNode<any, any>> =
|
|
54
|
+
TDocumentNode extends DocumentNode<infer TType, any> ? TType : never;
|