relay-test-utils 21.0.0 → 21.0.1
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.
|
@@ -63,33 +63,33 @@ type ValueResolver = (
|
|
|
63
63
|
defaultValue?: unknown,
|
|
64
64
|
) => unknown;
|
|
65
65
|
type Traversable = {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
66
|
+
readonly selections: ReadonlyArray<NormalizationSelection>,
|
|
67
|
+
readonly typeName: ?string,
|
|
68
|
+
readonly isAbstractType: ?boolean,
|
|
69
|
+
readonly name: ?string,
|
|
70
|
+
readonly alias: ?string,
|
|
71
|
+
readonly args: ?{[string]: unknown, ...},
|
|
72
72
|
};
|
|
73
73
|
type MockData = {[string]: unknown, ...};
|
|
74
74
|
export type MockResolverContext = {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
75
|
+
readonly parentType: ?string,
|
|
76
|
+
readonly name: ?string,
|
|
77
|
+
readonly alias: ?string,
|
|
78
|
+
readonly path: ?ReadonlyArray<string>,
|
|
79
|
+
readonly args: ?{[string]: unknown, ...},
|
|
80
80
|
};
|
|
81
81
|
type MockResolver = (
|
|
82
82
|
context: MockResolverContext,
|
|
83
83
|
generateId: () => number,
|
|
84
84
|
) => unknown;
|
|
85
|
-
export type MockResolvers = {
|
|
85
|
+
export type MockResolvers = {readonly [typeName: string]: MockResolver, ...};
|
|
86
86
|
|
|
87
87
|
type SelectionMetadata = {
|
|
88
88
|
[selectionPath: string]: {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
89
|
+
readonly type: string,
|
|
90
|
+
readonly plural: boolean,
|
|
91
|
+
readonly nullable: boolean,
|
|
92
|
+
readonly enumValues: ReadonlyArray<string> | null,
|
|
93
93
|
},
|
|
94
94
|
...
|
|
95
95
|
};
|
|
@@ -188,11 +188,11 @@ class RelayMockPayloadGenerator {
|
|
|
188
188
|
_deferredPayloads: Array<GraphQLResponseWithData>;
|
|
189
189
|
|
|
190
190
|
constructor(options: {
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
191
|
+
readonly variables: Variables,
|
|
192
|
+
readonly mockResolvers: MockResolvers | null,
|
|
193
|
+
readonly selectionMetadata: SelectionMetadata | null,
|
|
194
|
+
readonly mockClientData: ?boolean,
|
|
195
|
+
readonly generateDeferredPayload: ?boolean,
|
|
196
196
|
}) {
|
|
197
197
|
this._variables = options.variables;
|
|
198
198
|
this._mockResolvers = {
|
|
@@ -924,10 +924,10 @@ class RelayMockPayloadGenerator {
|
|
|
924
924
|
typeName: ?string,
|
|
925
925
|
selectionPath: ReadonlyArray<string>,
|
|
926
926
|
): {
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
927
|
+
readonly type: string,
|
|
928
|
+
readonly plural: boolean,
|
|
929
|
+
readonly enumValues: ReadonlyArray<string> | null,
|
|
930
|
+
readonly nullable: boolean,
|
|
931
931
|
} {
|
|
932
932
|
return (
|
|
933
933
|
this._getTypeDetailsForPath(selectionPath) ?? {
|
|
@@ -40,10 +40,10 @@ const {
|
|
|
40
40
|
} = require('relay-runtime');
|
|
41
41
|
|
|
42
42
|
type PendingRequest = {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
readonly request: RequestParameters,
|
|
44
|
+
readonly variables: Variables,
|
|
45
|
+
readonly cacheConfig: CacheConfig,
|
|
46
|
+
readonly sink: Sink<GraphQLSingularResponse>,
|
|
47
47
|
};
|
|
48
48
|
|
|
49
49
|
const MAX_SIZE = 10;
|
|
@@ -91,53 +91,53 @@ type OperationMockResolver = (
|
|
|
91
91
|
) => ?GraphQLSingularResponse | ?Error;
|
|
92
92
|
|
|
93
93
|
type MockFunctions = {
|
|
94
|
-
|
|
95
|
-
|
|
94
|
+
readonly clearCache: () => void,
|
|
95
|
+
readonly cachePayload: (
|
|
96
96
|
request: ConcreteRequest | OperationDescriptor,
|
|
97
97
|
variables: Variables,
|
|
98
98
|
payload: GraphQLSingularResponse,
|
|
99
99
|
) => void,
|
|
100
|
-
|
|
100
|
+
readonly isLoading: (
|
|
101
101
|
request: ConcreteRequest | OperationDescriptor,
|
|
102
102
|
variables: Variables,
|
|
103
103
|
cacheConfig?: CacheConfig,
|
|
104
104
|
) => boolean,
|
|
105
|
-
|
|
105
|
+
readonly reject: (
|
|
106
106
|
request: ConcreteRequest | OperationDescriptor,
|
|
107
107
|
error: Error | string,
|
|
108
108
|
) => void,
|
|
109
|
-
|
|
109
|
+
readonly nextValue: (
|
|
110
110
|
request: ConcreteRequest | OperationDescriptor,
|
|
111
111
|
payload: GraphQLSingularResponse,
|
|
112
112
|
) => void,
|
|
113
|
-
|
|
114
|
-
|
|
113
|
+
readonly complete: (request: ConcreteRequest | OperationDescriptor) => void,
|
|
114
|
+
readonly resolve: (
|
|
115
115
|
request: ConcreteRequest | OperationDescriptor,
|
|
116
116
|
payload: ReadonlyArray<GraphQLSingularResponse> | GraphQLSingularResponse,
|
|
117
117
|
) => void,
|
|
118
|
-
|
|
119
|
-
|
|
118
|
+
readonly getAllOperations: () => ReadonlyArray<OperationDescriptor>,
|
|
119
|
+
readonly findOperation: (
|
|
120
120
|
findFn: (operation: OperationDescriptor) => boolean,
|
|
121
121
|
) => OperationDescriptor,
|
|
122
|
-
|
|
122
|
+
readonly queuePendingOperation: (
|
|
123
123
|
query: GraphQLTaggedNode,
|
|
124
124
|
variables: Variables,
|
|
125
125
|
) => void,
|
|
126
|
-
|
|
127
|
-
|
|
126
|
+
readonly getMostRecentOperation: () => OperationDescriptor,
|
|
127
|
+
readonly resolveMostRecentOperation: (
|
|
128
128
|
payload:
|
|
129
129
|
| GraphQLSingularResponse
|
|
130
130
|
| ((operation: OperationDescriptor) => GraphQLSingularResponse),
|
|
131
131
|
) => void,
|
|
132
|
-
|
|
132
|
+
readonly rejectMostRecentOperation: (
|
|
133
133
|
error: Error | ((operation: OperationDescriptor) => Error),
|
|
134
134
|
) => void,
|
|
135
|
-
|
|
135
|
+
readonly queueOperationResolver: (resolver: OperationMockResolver) => void,
|
|
136
136
|
};
|
|
137
137
|
|
|
138
138
|
interface MockEnvironment {
|
|
139
|
-
|
|
140
|
-
|
|
139
|
+
readonly mock: MockFunctions;
|
|
140
|
+
readonly mockClear: () => void;
|
|
141
141
|
}
|
|
142
142
|
|
|
143
143
|
export interface RelayMockEnvironment extends MockEnvironment, IEnvironment {}
|
|
@@ -34,7 +34,7 @@ const {
|
|
|
34
34
|
* expect(actual).toEqual(expectedValue)
|
|
35
35
|
* ```
|
|
36
36
|
**/
|
|
37
|
-
function testResolver<D extends ?{
|
|
37
|
+
function testResolver<D extends ?{readonly $fragmentType?: unknown, ...}, Ret>(
|
|
38
38
|
resolver: ({$data?: D, $fragmentRefs: any, $fragmentSpreads: any}) => Ret,
|
|
39
39
|
// indexed_access is not yet enabled for this code base. Once it is, this can
|
|
40
40
|
// become: `Key['$data']`
|
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "relay-test-utils",
|
|
3
3
|
"description": "Utilities for testing Relay applications.",
|
|
4
|
-
"version": "21.0.
|
|
4
|
+
"version": "21.0.1",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"graphql",
|
|
7
7
|
"relay"
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"@babel/runtime": "^7.25.0",
|
|
19
19
|
"fbjs": "^3.0.2",
|
|
20
20
|
"invariant": "^2.2.4",
|
|
21
|
-
"relay-runtime": "21.0.
|
|
21
|
+
"relay-runtime": "21.0.1"
|
|
22
22
|
},
|
|
23
23
|
"directories": {
|
|
24
24
|
"": "./"
|