relay-runtime 0.0.0-main-1e923be9 → 0.0.0-main-764af24d
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/index.js +1 -1
- package/index.js.flow +2 -0
- package/lib/mutations/readUpdatableQuery_EXPERIMENTAL.js +3 -4
- package/lib/query/GraphQLTag.js +13 -0
- package/lib/store/RelayModernSelector.js +16 -2
- package/lib/util/RelayConcreteNode.js +1 -0
- package/mutations/RelayRecordSourceProxy.js.flow +7 -3
- package/mutations/RelayRecordSourceSelectorProxy.js.flow +7 -3
- package/mutations/readUpdatableQuery_EXPERIMENTAL.js.flow +14 -12
- package/package.json +1 -1
- package/query/GraphQLTag.js.flow +38 -3
- package/relay-runtime.js +2 -2
- package/relay-runtime.min.js +2 -2
- package/store/RelayModernSelector.js.flow +32 -8
- package/store/RelayStoreTypes.js.flow +4 -3
- package/util/RelayConcreteNode.js.flow +8 -1
- package/util/RelayRuntimeTypes.js.flow +20 -1
|
@@ -402,14 +402,7 @@ function getVariablesFromPluralFragment(
|
|
|
402
402
|
return variables;
|
|
403
403
|
}
|
|
404
404
|
|
|
405
|
-
|
|
406
|
-
* @public
|
|
407
|
-
*
|
|
408
|
-
* Determine if two selectors are equal (represent the same selection). Note
|
|
409
|
-
* that this function returns `false` when the two queries/fragments are
|
|
410
|
-
* different objects, even if they select the same fields.
|
|
411
|
-
*/
|
|
412
|
-
function areEqualSelectors(
|
|
405
|
+
function areEqualSingularSelectors(
|
|
413
406
|
thisSelector: SingularReaderSelector,
|
|
414
407
|
thatSelector: SingularReaderSelector,
|
|
415
408
|
): boolean {
|
|
@@ -421,6 +414,37 @@ function areEqualSelectors(
|
|
|
421
414
|
);
|
|
422
415
|
}
|
|
423
416
|
|
|
417
|
+
/**
|
|
418
|
+
* @public
|
|
419
|
+
*
|
|
420
|
+
* Determine if two selectors are equal (represent the same selection). Note
|
|
421
|
+
* that this function returns `false` when the two queries/fragments are
|
|
422
|
+
* different objects, even if they select the same fields.
|
|
423
|
+
*/
|
|
424
|
+
function areEqualSelectors(
|
|
425
|
+
a: ?(SingularReaderSelector | PluralReaderSelector),
|
|
426
|
+
b: ?(SingularReaderSelector | PluralReaderSelector),
|
|
427
|
+
): boolean {
|
|
428
|
+
if (
|
|
429
|
+
a?.kind === 'SingularReaderSelector' &&
|
|
430
|
+
b?.kind === 'SingularReaderSelector'
|
|
431
|
+
) {
|
|
432
|
+
return areEqualSingularSelectors(a, b);
|
|
433
|
+
} else if (
|
|
434
|
+
a?.kind === 'PluralReaderSelector' &&
|
|
435
|
+
b?.kind === 'PluralReaderSelector'
|
|
436
|
+
) {
|
|
437
|
+
return (
|
|
438
|
+
a.selectors.length === b.selectors.length &&
|
|
439
|
+
a.selectors.every((s, i) => areEqualSingularSelectors(s, b.selectors[i]))
|
|
440
|
+
);
|
|
441
|
+
} else if (a == null && b == null) {
|
|
442
|
+
return true;
|
|
443
|
+
} else {
|
|
444
|
+
return false;
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
|
|
424
448
|
function createReaderSelector(
|
|
425
449
|
fragment: ReaderFragment,
|
|
426
450
|
dataID: DataID,
|
|
@@ -44,8 +44,9 @@ import type {
|
|
|
44
44
|
CacheConfig,
|
|
45
45
|
DataID,
|
|
46
46
|
Disposable,
|
|
47
|
-
OperationType,
|
|
48
47
|
RenderPolicy,
|
|
48
|
+
UpdatableQuery,
|
|
49
|
+
UpdatableQueryType,
|
|
49
50
|
Variables,
|
|
50
51
|
} from '../util/RelayRuntimeTypes';
|
|
51
52
|
import type {InvalidationState} from './RelayModernStore';
|
|
@@ -466,8 +467,8 @@ export interface RecordSourceProxy {
|
|
|
466
467
|
get(dataID: DataID): ?RecordProxy;
|
|
467
468
|
getRoot(): RecordProxy;
|
|
468
469
|
invalidateStore(): void;
|
|
469
|
-
readUpdatableQuery_EXPERIMENTAL<TQuery:
|
|
470
|
-
query:
|
|
470
|
+
readUpdatableQuery_EXPERIMENTAL<TQuery: UpdatableQueryType>(
|
|
471
|
+
query: UpdatableQuery<TQuery['variables'], TQuery['response']>,
|
|
471
472
|
variables: TQuery['variables'],
|
|
472
473
|
): TQuery['response'];
|
|
473
474
|
}
|
|
@@ -31,6 +31,11 @@ export type ConcreteRequest = {|
|
|
|
31
31
|
+params: RequestParameters,
|
|
32
32
|
|};
|
|
33
33
|
|
|
34
|
+
export type ConcreteUpdatableQuery = {|
|
|
35
|
+
+kind: 'UpdatableQuery',
|
|
36
|
+
+fragment: ReaderFragment,
|
|
37
|
+
|};
|
|
38
|
+
|
|
34
39
|
export type NormalizationRootNode =
|
|
35
40
|
| ConcreteRequest
|
|
36
41
|
| NormalizationSplitOperation;
|
|
@@ -68,7 +73,8 @@ export type GeneratedNode =
|
|
|
68
73
|
| ConcreteRequest
|
|
69
74
|
| ReaderFragment
|
|
70
75
|
| ReaderInlineDataFragment
|
|
71
|
-
| NormalizationSplitOperation
|
|
76
|
+
| NormalizationSplitOperation
|
|
77
|
+
| ConcreteUpdatableQuery;
|
|
72
78
|
|
|
73
79
|
const RelayConcreteNode = {
|
|
74
80
|
ACTOR_CHANGE: 'ActorChange',
|
|
@@ -101,6 +107,7 @@ const RelayConcreteNode = {
|
|
|
101
107
|
SPLIT_OPERATION: 'SplitOperation',
|
|
102
108
|
STREAM: 'Stream',
|
|
103
109
|
TYPE_DISCRIMINATOR: 'TypeDiscriminator',
|
|
110
|
+
UPDATABLE_QUERY: 'UpdatableQuery',
|
|
104
111
|
VARIABLE: 'Variable',
|
|
105
112
|
};
|
|
106
113
|
|
|
@@ -17,7 +17,10 @@
|
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
19
|
import type {ReaderFragment, ReaderInlineDataFragment} from './ReaderNode';
|
|
20
|
-
import type {
|
|
20
|
+
import type {
|
|
21
|
+
ConcreteRequest,
|
|
22
|
+
ConcreteUpdatableQuery,
|
|
23
|
+
} from './RelayConcreteNode';
|
|
21
24
|
|
|
22
25
|
/**
|
|
23
26
|
* Represents any resource that must be explicitly disposed of. The most common
|
|
@@ -41,6 +44,14 @@ export type OperationType = {|
|
|
|
41
44
|
+rawResponse?: {...},
|
|
42
45
|
|};
|
|
43
46
|
|
|
47
|
+
/**
|
|
48
|
+
* Generated updatable query flow types are subtypes of this.
|
|
49
|
+
*/
|
|
50
|
+
export type UpdatableQueryType = {|
|
|
51
|
+
+variables: Variables,
|
|
52
|
+
+response: mixed,
|
|
53
|
+
|};
|
|
54
|
+
|
|
44
55
|
export type VariablesOf<T: OperationType> = T['variables'];
|
|
45
56
|
|
|
46
57
|
/**
|
|
@@ -84,6 +95,14 @@ declare export opaque type Operation<
|
|
|
84
95
|
TRawResponse,
|
|
85
96
|
>: ConcreteRequest;
|
|
86
97
|
|
|
98
|
+
/**
|
|
99
|
+
* Return type of graphql tag literals for updatable queries.
|
|
100
|
+
*/
|
|
101
|
+
declare export opaque type UpdatableQuery<
|
|
102
|
+
-TVariables: Variables,
|
|
103
|
+
+TData,
|
|
104
|
+
>: ConcreteUpdatableQuery;
|
|
105
|
+
|
|
87
106
|
/**
|
|
88
107
|
* Return type of graphql tag literals for queries.
|
|
89
108
|
*/
|