-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Expand file tree
/
Copy pathRelayConcreteNode.js
More file actions
140 lines (127 loc) · 4.36 KB
/
Copy pathRelayConcreteNode.js
File metadata and controls
140 lines (127 loc) · 4.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict-local
* @format
* @oncall relay
*/
'use strict';
import type {
NormalizationOperation,
NormalizationSplitOperation,
} from './NormalizationNode';
import type {ReaderFragment, ReaderInlineDataFragment} from './ReaderNode';
/**
* Represents a common GraphQL request that can be executed, an `operation`
* containing information to normalize the results, and a `fragment` derived
* from that operation to read the response data (masking data from child
* fragments).
*/
export type ConcreteRequest = {
readonly kind: 'Request',
readonly fragment: ReaderFragment,
readonly operation: NormalizationOperation,
readonly params: RequestParameters,
};
export type ConcreteUpdatableQuery = {
readonly kind: 'UpdatableQuery',
readonly fragment: ReaderFragment,
};
export type NormalizationRootNode =
ConcreteRequest | NormalizationSplitOperation;
export type ProvidedVariableType = {get(): unknown};
export type ProvidedVariablesType = {readonly [key: string]: {get(): unknown}};
/**
* Contains the parameters required for executing a GraphQL request.
* The operation can either be provided as a persisted `id` or `text` or both.
* If `text` format is provided, a `cacheID` as a hash of the text should be set
* to be used for local caching.
*/
export type RequestParameters =
| {
readonly id: string,
readonly text: string | null,
// Optional when the compiler is configured with `include_query_text: true`
// for persisted queries — artifacts then carry both `id` and `text`, and a
// `cacheID` (hash of the text) for local caching. See the doc comment above.
readonly cacheID?: string,
// common fields
readonly name: string,
readonly operationKind: 'mutation' | 'query' | 'subscription',
readonly providedVariables?: ProvidedVariablesType,
readonly metadata: {[key: string]: unknown, ...},
}
| {
readonly cacheID: string,
readonly id: null,
readonly text: string | null,
// common fields
readonly name: string,
readonly operationKind: 'mutation' | 'query' | 'subscription',
readonly providedVariables?: ProvidedVariablesType,
readonly metadata: {[key: string]: unknown, ...},
};
export type ClientRequestParameters = {
readonly cacheID: string,
readonly id: null,
readonly text: null,
// common fields
readonly name: string,
readonly operationKind: 'query' | 'mutation',
readonly providedVariables?: ProvidedVariablesType,
readonly metadata: {[key: string]: unknown, ...},
};
export type ClientRequest = {
readonly kind: 'Request',
readonly fragment: ReaderFragment,
readonly operation: NormalizationOperation,
readonly params: ClientRequestParameters,
};
export type GeneratedNode =
| ConcreteRequest
| ReaderFragment
| ReaderInlineDataFragment
| NormalizationSplitOperation
| ConcreteUpdatableQuery;
const RelayConcreteNode = {
ACTOR_CHANGE: 'ActorChange',
CATCH_FIELD: 'CatchField',
CONDITION: 'Condition',
CLIENT_COMPONENT: 'ClientComponent',
CLIENT_EDGE_TO_SERVER_OBJECT: 'ClientEdgeToServerObject',
CLIENT_EDGE_TO_CLIENT_OBJECT: 'ClientEdgeToClientObject',
CLIENT_EXTENSION: 'ClientExtension',
DEFER: 'Defer',
CONNECTION: 'Connection',
FRAGMENT: 'Fragment',
FRAGMENT_SPREAD: 'FragmentSpread',
INLINE_DATA_FRAGMENT_SPREAD: 'InlineDataFragmentSpread',
INLINE_DATA_FRAGMENT: 'InlineDataFragment',
INLINE_FRAGMENT: 'InlineFragment',
LINKED_FIELD: 'LinkedField',
LINKED_HANDLE: 'LinkedHandle',
LITERAL: 'Literal',
LIST_VALUE: 'ListValue',
LOCAL_ARGUMENT: 'LocalArgument',
MODULE_IMPORT: 'ModuleImport',
ALIASED_FRAGMENT_SPREAD: 'AliasedFragmentSpread',
ALIASED_INLINE_FRAGMENT_SPREAD: 'AliasedInlineFragmentSpread',
RELAY_RESOLVER: 'RelayResolver',
RELAY_LIVE_RESOLVER: 'RelayLiveResolver',
REQUIRED_FIELD: 'RequiredField',
OBJECT_VALUE: 'ObjectValue',
OPERATION: 'Operation',
REQUEST: 'Request',
ROOT_ARGUMENT: 'RootArgument',
SCALAR_FIELD: 'ScalarField',
SCALAR_HANDLE: 'ScalarHandle',
SPLIT_OPERATION: 'SplitOperation',
STREAM: 'Stream',
TYPE_DISCRIMINATOR: 'TypeDiscriminator',
UPDATABLE_QUERY: 'UpdatableQuery',
VARIABLE: 'Variable',
} as const;
module.exports = RelayConcreteNode;