@oanda/labs-instrument-live-rate-widget 1.0.33 → 1.0.35

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 (77) hide show
  1. package/CHANGELOG.md +284 -0
  2. package/dist/main/InstrumentLiveRateWidget/InstrumentLiveRateWidget.js +27 -27
  3. package/dist/main/InstrumentLiveRateWidget/InstrumentLiveRateWidget.js.map +1 -1
  4. package/dist/main/InstrumentLiveRateWidget/Main.js +5 -5
  5. package/dist/main/InstrumentLiveRateWidget/Main.js.map +1 -1
  6. package/dist/main/InstrumentLiveRateWidget/ValidationWrapper.js +6 -8
  7. package/dist/main/InstrumentLiveRateWidget/ValidationWrapper.js.map +1 -1
  8. package/dist/main/InstrumentLiveRateWidget/constant.js.map +1 -1
  9. package/dist/main/InstrumentLiveRateWidget/render.js +7 -7
  10. package/dist/main/InstrumentLiveRateWidget/render.js.map +1 -1
  11. package/dist/main/InstrumentLiveRateWidget/types.js +1 -1
  12. package/dist/main/InstrumentLiveRateWidget/types.js.map +1 -1
  13. package/dist/main/InstrumentLiveRateWidget/utils.js +1 -1
  14. package/dist/main/InstrumentLiveRateWidget/utils.js.map +1 -1
  15. package/dist/main/gql/types/fragment-masking.js.map +1 -1
  16. package/dist/main/gql/types/gql.js +2 -2
  17. package/dist/main/gql/types/gql.js.map +1 -1
  18. package/dist/main/gql/types/graphql.js +142 -142
  19. package/dist/main/gql/types/graphql.js.map +1 -1
  20. package/dist/main/gql/types/index.js.map +1 -1
  21. package/dist/main/index.js +8 -8
  22. package/dist/main/index.js.map +1 -1
  23. package/dist/main/translations/index.js +1 -1
  24. package/dist/main/translations/index.js.map +1 -1
  25. package/dist/main/translations/translations.js.map +1 -1
  26. package/dist/module/InstrumentLiveRateWidget/InstrumentLiveRateWidget.js +28 -27
  27. package/dist/module/InstrumentLiveRateWidget/InstrumentLiveRateWidget.js.map +1 -1
  28. package/dist/module/InstrumentLiveRateWidget/Main.js +5 -5
  29. package/dist/module/InstrumentLiveRateWidget/Main.js.map +1 -1
  30. package/dist/module/InstrumentLiveRateWidget/ValidationWrapper.js +6 -6
  31. package/dist/module/InstrumentLiveRateWidget/ValidationWrapper.js.map +1 -1
  32. package/dist/module/InstrumentLiveRateWidget/constant.js.map +1 -1
  33. package/dist/module/InstrumentLiveRateWidget/render.js +7 -7
  34. package/dist/module/InstrumentLiveRateWidget/render.js.map +1 -1
  35. package/dist/module/InstrumentLiveRateWidget/types.js +1 -1
  36. package/dist/module/InstrumentLiveRateWidget/types.js.map +1 -1
  37. package/dist/module/InstrumentLiveRateWidget/utils.js +1 -1
  38. package/dist/module/InstrumentLiveRateWidget/utils.js.map +1 -1
  39. package/dist/module/gql/types/fragment-masking.js.map +1 -1
  40. package/dist/module/gql/types/gql.js +2 -2
  41. package/dist/module/gql/types/gql.js.map +1 -1
  42. package/dist/module/gql/types/graphql.js +142 -142
  43. package/dist/module/gql/types/graphql.js.map +1 -1
  44. package/dist/module/gql/types/index.js +2 -2
  45. package/dist/module/gql/types/index.js.map +1 -1
  46. package/dist/module/index.js +1 -1
  47. package/dist/module/index.js.map +1 -1
  48. package/dist/module/translations/index.js +1 -1
  49. package/dist/module/translations/index.js.map +1 -1
  50. package/dist/module/translations/translations.js.map +1 -1
  51. package/dist/types/InstrumentLiveRateWidget/InstrumentLiveRateWidget.d.ts +1 -1
  52. package/dist/types/InstrumentLiveRateWidget/Main.d.ts +1 -1
  53. package/dist/types/InstrumentLiveRateWidget/ValidationWrapper.d.ts +1 -1
  54. package/dist/types/InstrumentLiveRateWidget/constant.d.ts +1 -1
  55. package/dist/types/InstrumentLiveRateWidget/types.d.ts +3 -3
  56. package/dist/types/InstrumentLiveRateWidget/utils.d.ts +3 -3
  57. package/dist/types/gql/types/gql.d.ts +4 -4
  58. package/dist/types/gql/types/index.d.ts +2 -2
  59. package/dist/types/index.d.ts +1 -1
  60. package/dist/types/translations/index.d.ts +2 -2
  61. package/package.json +3 -3
  62. package/src/InstrumentLiveRateWidget/InstrumentLiveRateWidget.tsx +32 -30
  63. package/src/InstrumentLiveRateWidget/Main.tsx +12 -8
  64. package/src/InstrumentLiveRateWidget/ValidationWrapper.tsx +33 -29
  65. package/src/InstrumentLiveRateWidget/constant.ts +1 -3
  66. package/src/InstrumentLiveRateWidget/render.tsx +44 -31
  67. package/src/InstrumentLiveRateWidget/types.tsx +8 -3
  68. package/src/InstrumentLiveRateWidget/utils.ts +16 -16
  69. package/src/gql/types/fragment-masking.ts +41 -21
  70. package/src/gql/types/gql.ts +12 -5
  71. package/src/gql/types/graphql.ts +214 -50
  72. package/src/gql/types/index.ts +2 -2
  73. package/src/index.ts +1 -1
  74. package/src/translations/index.ts +4 -4
  75. package/src/translations/translations.ts +2 -1
  76. package/test/Main.test.tsx +21 -15
  77. package/test/mocks.ts +1 -3
@@ -1,4 +1,4 @@
1
- import { Translations } from '@oanda/mono-i18n';
2
- import { defaultTranslations } from './translations';
1
+ import type { Translations } from '@oanda/mono-i18n';
2
+ import type { defaultTranslations } from './translations';
3
3
  export type TranslationKey = keyof typeof defaultTranslations;
4
4
  export declare const translations: Translations;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oanda/labs-instrument-live-rate-widget",
3
- "version": "1.0.33",
3
+ "version": "1.0.35",
4
4
  "description": "Labs Instrument Live Rate Widget",
5
5
  "main": "dist/main/index.js",
6
6
  "module": "dist/module/index.js",
@@ -12,7 +12,7 @@
12
12
  "author": "OANDA",
13
13
  "license": "UNLICENSED",
14
14
  "dependencies": {
15
- "@oanda/labs-widget-common": "^1.0.172",
15
+ "@oanda/labs-widget-common": "^1.0.174",
16
16
  "@oanda/mono-i18n": "10.0.1",
17
17
  "graphql": "16.8.1"
18
18
  },
@@ -20,5 +20,5 @@
20
20
  "@graphql-codegen/cli": "5.0.0",
21
21
  "@graphql-codegen/client-preset": "4.1.0"
22
22
  },
23
- "gitHead": "f3c94dbb01bc271f175ba95700c51001c4099a52"
23
+ "gitHead": "4c5d84b00c7fbf3acd7ef27634fbd2a9ef0afd6b"
24
24
  }
@@ -1,12 +1,10 @@
1
- import React, { Suspense } from 'react';
2
- import { ApolloClient, InMemoryCache, ApolloProvider } from '@apollo/client';
3
- import { LocaleProvider } from '@oanda/mono-i18n';
4
- import {
5
- LiveRatesProvider, ThemeProvider, getLocale,
6
- renderComponent,
7
- } from '@oanda/labs-widget-common';
1
+ import { ApolloClient, InMemoryCache } from '@apollo/client';
2
+ import { WidgetProvider, WidgetWrapper } from '@oanda/labs-widget-common';
3
+ import React from 'react';
4
+
8
5
  import { translations } from '../translations';
9
- import { Division, InstrumentLiveRateConfig } from './types';
6
+ import type { InstrumentLiveRateConfig } from './types';
7
+ import { Division } from './types';
10
8
  import { ValidationWrapper } from './ValidationWrapper';
11
9
 
12
10
  const InstrumentLiveRateWidget = ({
@@ -30,29 +28,33 @@ const InstrumentLiveRateWidget = ({
30
28
  const dataSource = divisionCode === Division.Ogm ? 'MT5' : 'V20';
31
29
 
32
30
  return (
33
- <LocaleProvider locale={getLocale(locale)} translations={translations}>
34
- <LiveRatesProvider
35
- url={liveRatesUrl}
36
- options={{ divisionCode, dataSource }}
31
+ <WidgetProvider
32
+ withSuspense
33
+ client={client}
34
+ liveRates={{
35
+ url: liveRatesUrl,
36
+ options: { divisionCode, dataSource },
37
+ }}
38
+ locale={locale}
39
+ styling={{
40
+ removePadding,
41
+ }}
42
+ theme={theme}
43
+ translations={translations}
44
+ >
45
+ <WidgetWrapper
46
+ isParamError={isParamError}
47
+ linkArea="full"
48
+ logoLink={logoLink}
37
49
  >
38
- <ApolloProvider client={client}>
39
- <Suspense>
40
- <ThemeProvider removePadding={removePadding} theme={theme}>
41
- {renderComponent({
42
- Component: <ValidationWrapper
43
- size={size}
44
- instrument={instrument}
45
- division={division}
46
- isParamError={isParamError}
47
- />,
48
- logoLink,
49
- linkArea: 'full',
50
- })}
51
- </ThemeProvider>
52
- </Suspense>
53
- </ApolloProvider>
54
- </LiveRatesProvider>
55
- </LocaleProvider>
50
+ <ValidationWrapper
51
+ division={division}
52
+ instrument={instrument}
53
+ isParamError={isParamError}
54
+ size={size}
55
+ />
56
+ </WidgetWrapper>
57
+ </WidgetProvider>
56
58
  );
57
59
  };
58
60
 
@@ -1,14 +1,18 @@
1
- import React, { useEffect } from 'react';
2
1
  import { useBackgroundQuery } from '@apollo/client';
3
2
  import {
4
3
  InstrumentRateWithChart,
5
4
  Tooltip,
6
5
  useLiveRatesQuery,
7
6
  } from '@oanda/labs-widget-common';
8
- import { MainProps } from './types';
9
- import { INSTRUMENT_TOOLTIP_ID } from './constant';
7
+ import React, { useEffect } from 'react';
8
+
10
9
  import { getInstrumentsChart } from '../gql/getInstrumentsChart';
11
- import { GetInstrumentsChartQuery, GetInstrumentsChartQueryVariables } from '../gql/types/graphql';
10
+ import type {
11
+ GetInstrumentsChartQuery,
12
+ GetInstrumentsChartQueryVariables,
13
+ } from '../gql/types/graphql';
14
+ import { INSTRUMENT_TOOLTIP_ID } from './constant';
15
+ import type { MainProps } from './types';
12
16
 
13
17
  const Main = ({
14
18
  division,
@@ -18,8 +22,8 @@ const Main = ({
18
22
  const hasInstrument = !!record.instrument;
19
23
 
20
24
  const [queryRef] = useBackgroundQuery<
21
- GetInstrumentsChartQuery,
22
- GetInstrumentsChartQueryVariables
25
+ GetInstrumentsChartQuery,
26
+ GetInstrumentsChartQueryVariables
23
27
  >(getInstrumentsChart, {
24
28
  variables: {
25
29
  instruments: [record.instrument],
@@ -41,11 +45,11 @@ const Main = ({
41
45
  return (
42
46
  <div>
43
47
  <InstrumentRateWithChart<GetInstrumentsChartQuery>
48
+ queryRef={queryRef}
44
49
  record={record}
45
- target={target}
46
50
  size={widgetSize}
51
+ target={target}
47
52
  tooltipId={INSTRUMENT_TOOLTIP_ID}
48
- queryRef={queryRef}
49
53
  />
50
54
  <Tooltip id={INSTRUMENT_TOOLTIP_ID} />
51
55
  </div>
@@ -1,12 +1,16 @@
1
- import React, { useContext } from 'react';
2
1
  import { useSuspenseQuery } from '@apollo/client';
2
+ import { Error, useLayoutProvider } from '@oanda/labs-widget-common';
3
3
  import classnames from 'classnames';
4
- import { Error, ThemeContext } from '@oanda/labs-widget-common';
5
- import { getRecords } from './utils';
6
- import { ValidationWrapperProps } from './types';
4
+ import React from 'react';
5
+
6
+ import type {
7
+ ValidateInstrumentsQuery,
8
+ ValidateInstrumentsQueryVariables,
9
+ } from '../gql/types/graphql';
7
10
  import { validateInstruments } from '../gql/validateInstruments';
8
- import { ValidateInstrumentsQuery, ValidateInstrumentsQueryVariables } from '../gql/types/graphql';
9
11
  import { Main } from './Main';
12
+ import type { ValidationWrapperProps } from './types';
13
+ import { getRecords } from './utils';
10
14
 
11
15
  const ValidationWrapper = ({
12
16
  instrument,
@@ -14,10 +18,10 @@ const ValidationWrapper = ({
14
18
  size: widgetSize,
15
19
  isParamError,
16
20
  }: ValidationWrapperProps) => {
17
- const { size } = useContext(ThemeContext);
21
+ const { size } = useLayoutProvider();
18
22
  const { data, error } = useSuspenseQuery<
19
- ValidateInstrumentsQuery,
20
- ValidateInstrumentsQueryVariables
23
+ ValidateInstrumentsQuery,
24
+ ValidateInstrumentsQueryVariables
21
25
  >(validateInstruments, {
22
26
  variables: {
23
27
  instruments: [instrument],
@@ -32,30 +36,30 @@ const ValidationWrapper = ({
32
36
  return (
33
37
  <>
34
38
  {size && (
35
- <div
36
- className="lw-flex lw-border lw-border-solid lw-border-border-primary lw-px-4 lw-text-sm lw-tracking-normal lw-text-text-primary"
37
- >
39
+ <div className="lw-flex lw-border lw-border-solid lw-border-border-primary lw-px-4 lw-text-sm lw-tracking-normal lw-text-text-primary">
38
40
  {!showError && (
39
- <div className={classnames({
40
- 'lw-h-[82px]': widgetSize !== 'compact',
41
- 'lw-h-[54px]': widgetSize === 'compact',
42
- })}
43
- >
44
- <Main
45
- size={widgetSize}
46
- division={division}
47
- record={getRecords(data!)?.[0]!}
48
- />
49
- </div>
41
+ <div
42
+ className={classnames({
43
+ 'lw-h-[82px]': widgetSize !== 'compact',
44
+ 'lw-h-[54px]': widgetSize === 'compact',
45
+ })}
46
+ >
47
+ <Main
48
+ division={division}
49
+ record={getRecords(data!)?.[0]!}
50
+ size={widgetSize}
51
+ />
52
+ </div>
50
53
  )}
51
54
  {showError && (
52
- <div className={classnames('lw-flex lw-w-full lw-items-center', {
53
- 'lw-h-[82px]': widgetSize !== 'compact',
54
- 'lw-h-[54px]': widgetSize === 'compact',
55
- })}
56
- >
57
- <Error />
58
- </div>
55
+ <div
56
+ className={classnames('lw-flex lw-w-full lw-items-center', {
57
+ 'lw-h-[82px]': widgetSize !== 'compact',
58
+ 'lw-h-[54px]': widgetSize === 'compact',
59
+ })}
60
+ >
61
+ <Error />
62
+ </div>
59
63
  )}
60
64
  </div>
61
65
  )}
@@ -1,5 +1,3 @@
1
1
  const INSTRUMENT_TOOLTIP_ID = 'instrument_tooltip_id';
2
2
 
3
- export {
4
- INSTRUMENT_TOOLTIP_ID,
5
- };
3
+ export { INSTRUMENT_TOOLTIP_ID };
@@ -1,51 +1,64 @@
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
- import { Theme, validateLocale, validateToolParams } from '@oanda/labs-widget-common';
4
- import { InstrumentLiveRateWidget } from './InstrumentLiveRateWidget';
5
+
5
6
  import { Division } from '../gql/types/graphql';
7
+ import { InstrumentLiveRateWidget } from './InstrumentLiveRateWidget';
6
8
 
7
- const {
8
- graphqlUrl,
9
- liveRatesUrl,
10
- } = window.widgetsConfig || {};
9
+ const { graphqlUrl, liveRatesUrl } = window.widgetsConfig || {};
11
10
 
12
- const instrumentLiveRateElements = document.querySelectorAll('div[data-instrument-live-rate-params]');
11
+ const instrumentLiveRateElements = document.querySelectorAll(
12
+ 'div[data-instrument-live-rate-params]'
13
+ );
13
14
 
14
15
  instrumentLiveRateElements.forEach((element) => {
15
16
  const root = createRoot(element);
16
17
  const params = element.getAttribute('data-instrument-live-rate-params');
17
18
  const mode = element.getAttribute('data-mode');
18
- const {
19
- instrument, division, locale, size,
20
- } = JSON.parse(params as string);
19
+ const { instrument, division, locale, size } = JSON.parse(params as string);
21
20
 
22
- const isParamError = validateToolParams({
23
- division, locale, instrument, graphqlUrl, liveRatesUrl,
24
- }, [{
25
- name: 'locale',
26
- valueCheck: (value) => validateLocale(value),
27
- }, {
28
- name: 'division',
29
- valueCheck: (value) => Object.values(Division).includes(value),
30
- }, {
31
- name: 'instrument',
32
- valueCheck: (value) => (value as string).length > 0,
33
- }, {
34
- name: 'graphqlUrl',
35
- }, {
36
- name: 'liveRatesUrl',
37
- }]);
21
+ const isParamError = validateToolParams(
22
+ {
23
+ division,
24
+ locale,
25
+ instrument,
26
+ graphqlUrl,
27
+ liveRatesUrl,
28
+ },
29
+ [
30
+ {
31
+ name: 'locale',
32
+ valueCheck: (value: string | undefined) => validateLocale(value),
33
+ },
34
+ {
35
+ name: 'division',
36
+ valueCheck: (value: Division) =>
37
+ Object.values(Division).includes(value),
38
+ },
39
+ {
40
+ name: 'instrument',
41
+ valueCheck: (value) => (value as string).length > 0,
42
+ },
43
+ {
44
+ name: 'graphqlUrl',
45
+ },
46
+ {
47
+ name: 'liveRatesUrl',
48
+ },
49
+ ]
50
+ );
38
51
 
39
52
  root.render(
40
53
  <InstrumentLiveRateWidget
41
- graphqlUrl={graphqlUrl}
42
- liveRatesUrl={liveRatesUrl}
43
54
  division={division}
55
+ graphqlUrl={graphqlUrl}
44
56
  instrument={instrument}
45
- locale={locale}
46
- theme={mode as Theme}
47
57
  isParamError={isParamError}
58
+ liveRatesUrl={liveRatesUrl}
59
+ locale={locale}
48
60
  size={size}
49
- />,
61
+ theme={mode as Theme}
62
+ />
50
63
  );
51
64
  });
@@ -1,8 +1,13 @@
1
- import { DataRecord, WidgetConfig, WidgetSize } from '@oanda/labs-widget-common';
2
- import { Division } from '../gql/types/graphql';
1
+ import type {
2
+ DataRecord,
3
+ WidgetConfig,
4
+ WidgetSize,
5
+ } from '@oanda/labs-widget-common';
6
+
7
+ import type { Division } from '../gql/types/graphql';
3
8
 
4
- export { Locale } from '@oanda/mono-i18n';
5
9
  export { Division } from '../gql/types/graphql';
10
+ export { Locale } from '@oanda/mono-i18n';
6
11
 
7
12
  export interface InstrumentLiveRateConfig extends WidgetConfig {
8
13
  division: Division;
@@ -1,16 +1,19 @@
1
- import { useState, useEffect } from 'react';
2
- import { DataRecord, LiveRatesErrorMessage, useLiveRatesMessage } from '@oanda/labs-widget-common';
3
- import { ValidateInstrumentsQuery } from '../gql/types/graphql';
1
+ import type {
2
+ DataRecord,
3
+ LiveRatesErrorMessage,
4
+ } from '@oanda/labs-widget-common';
5
+ import { useLiveRatesMessage } from '@oanda/labs-widget-common';
6
+ import { useEffect, useState } from 'react';
4
7
 
5
- const getRecords = (data: ValidateInstrumentsQuery) => data?.mapInstrumentNames?.map((item) => ({
6
- instrument: item?.name || '',
7
- displayName: item?.displayName || '',
8
- }));
8
+ import type { ValidateInstrumentsQuery } from '../gql/types/graphql';
9
9
 
10
- const useRecords = (
11
- record: DataRecord,
12
- target: EventTarget | null,
13
- ) => {
10
+ const getRecords = (data: ValidateInstrumentsQuery) =>
11
+ data?.mapInstrumentNames?.map((item) => ({
12
+ instrument: item?.name || '',
13
+ displayName: item?.displayName || '',
14
+ }));
15
+
16
+ const useRecords = (record: DataRecord, target: EventTarget | null) => {
14
17
  const [updatedRecord, setUpdatedRecord] = useState<DataRecord>({
15
18
  displayName: record.displayName,
16
19
  instrument: record.instrument,
@@ -20,7 +23,7 @@ const useRecords = (
20
23
 
21
24
  const { update, error: liveRatesError } = useLiveRatesMessage(
22
25
  record.instrument,
23
- target,
26
+ target
24
27
  );
25
28
 
26
29
  useEffect(() => {
@@ -42,7 +45,4 @@ const useRecords = (
42
45
  };
43
46
  };
44
47
 
45
- export {
46
- getRecords,
47
- useRecords,
48
- };
48
+ export { getRecords, useRecords };
@@ -1,18 +1,21 @@
1
- import { ResultOf, DocumentTypeDecoration, TypedDocumentNode } from '@graphql-typed-document-node/core';
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
- export type FragmentType<TDocumentType extends DocumentTypeDecoration<any, any>> = TDocumentType extends DocumentTypeDecoration<
7
- infer TType,
8
- any
9
- >
10
- ? [TType] extends [{ ' $fragmentName'?: infer TKey }]
11
- ? TKey extends string
12
- ? { ' $fragmentRefs'?: { [key in TKey]: TType } }
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: FragmentType<DocumentTypeDecoration<TType, any>> | null | undefined
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: ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>>> | null | undefined
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: FragmentType<DocumentTypeDecoration<TType, any>> | ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>>> | null | undefined
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: FragmentType<TypedDocumentNode<Incremental<TFrag>, any>> | null | undefined
66
+ data:
67
+ | FragmentType<TypedDocumentNode<Incremental<TFrag>, any>>
68
+ | null
69
+ | undefined
55
70
  ): data is FragmentType<typeof fragmentNode> {
56
- const deferredFields = (queryNode as { __meta__?: { deferredFields: Record<string, (keyof TFrag)[]> } }).__meta__
57
- ?.deferredFields;
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 FragmentDefinitionNode | undefined;
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
  }
@@ -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
- "\n query GetInstrumentsChart($instruments: [String!], $division: Division) {\n topicalInstrumentsCharts(instruments: $instruments, division: $division) {\n name\n chart\n }\n }\n": types.GetInstrumentsChartDocument,
17
- "\n query validateInstruments($instruments: [String]!, $division: Division) {\n mapInstrumentNames(instruments: $instruments, division: $division) {\n name\n displayName\n }\n }\n": types.ValidateInstrumentsDocument,
16
+ '\n query GetInstrumentsChart($instruments: [String!], $division: Division) {\n topicalInstrumentsCharts(instruments: $instruments, division: $division) {\n name\n chart\n }\n }\n':
17
+ types.GetInstrumentsChartDocument,
18
+ '\n query validateInstruments($instruments: [String]!, $division: Division) {\n mapInstrumentNames(instruments: $instruments, division: $division) {\n name\n displayName\n }\n }\n':
19
+ types.ValidateInstrumentsDocument,
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(source: "\n query GetInstrumentsChart($instruments: [String!], $division: Division) {\n topicalInstrumentsCharts(instruments: $instruments, division: $division) {\n name\n chart\n }\n }\n"): (typeof documents)["\n query GetInstrumentsChart($instruments: [String!], $division: Division) {\n topicalInstrumentsCharts(instruments: $instruments, division: $division) {\n name\n chart\n }\n }\n"];
39
+ export function graphql(
40
+ source: '\n query GetInstrumentsChart($instruments: [String!], $division: Division) {\n topicalInstrumentsCharts(instruments: $instruments, division: $division) {\n name\n chart\n }\n }\n'
41
+ ): (typeof documents)['\n query GetInstrumentsChart($instruments: [String!], $division: Division) {\n topicalInstrumentsCharts(instruments: $instruments, division: $division) {\n name\n chart\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(source: "\n query validateInstruments($instruments: [String]!, $division: Division) {\n mapInstrumentNames(instruments: $instruments, division: $division) {\n name\n displayName\n }\n }\n"): (typeof documents)["\n query validateInstruments($instruments: [String]!, $division: Division) {\n mapInstrumentNames(instruments: $instruments, division: $division) {\n name\n displayName\n }\n }\n"];
45
+ export function graphql(
46
+ source: '\n query validateInstruments($instruments: [String]!, $division: Division) {\n mapInstrumentNames(instruments: $instruments, division: $division) {\n name\n displayName\n }\n }\n'
47
+ ): (typeof documents)['\n query validateInstruments($instruments: [String]!, $division: Division) {\n mapInstrumentNames(instruments: $instruments, division: $division) {\n name\n displayName\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>> = TDocumentNode extends DocumentNode< infer TType, any> ? TType : never;
53
+ export type DocumentType<TDocumentNode extends DocumentNode<any, any>> =
54
+ TDocumentNode extends DocumentNode<infer TType, any> ? TType : never;