Skip to content

Commit 94d5415

Browse files
committed
relay v20
1 parent fcd611d commit 94d5415

File tree

8 files changed

+97
-76
lines changed

8 files changed

+97
-76
lines changed

packages/relay-offline/__tests__/RelayModernEnvironment-CommitPayload-test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,6 @@ describe('commitPayload()', () => {
147147
me: {
148148
name: 'Zuck',
149149
__id: id,
150-
__isWithinUnmatchedTypeRefinement: false,
151150
__fragments: { RelayModernEnvironmentCommitPayloadTestActorUserFragment: {} },
152151
__fragmentOwner: operation.request,
153152
},

packages/relay-offline/__tests__/RelayModernEnvironment-Connection-test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,6 @@ describe('@connection', () => {
141141
expect(nextOperationSnapshot.data).toEqual({
142142
node: {
143143
__id: '<feedbackid>',
144-
__isWithinUnmatchedTypeRefinement: false,
145144

146145
__fragments: {
147146
RelayModernEnvironmentConnectionTestFeedbackFragment: {},

packages/relay-offline/__tests__/RelayModernEnvironment-ExecuteMutationWithMatch-test.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -294,13 +294,12 @@ describe.each(['RelayModernEnvironment'])('executeMutation() with @match', (envi
294294
actor: {
295295
name: 'actor-name',
296296
nameRenderer: {
297-
__id: 'client:4:nameRenderer(supported:["PlainUserNameRenderer","MarkdownUserNameRenderer"])',
297+
__id: 'client:4:nameRenderer(supported:"34hjiS")',
298298
__fragmentPropName: 'name',
299299
__fragments: {
300300
RelayModernEnvironmentExecuteMutationWithMatchTestMarkdownUserNameRenderer_name: {},
301301
},
302302
__fragmentOwner: operation.request,
303-
__isWithinUnmatchedTypeRefinement: false,
304303
__module_component: 'MarkdownUserNameRenderer.react',
305304
},
306305
},
@@ -564,13 +563,12 @@ describe.each(['RelayModernEnvironment'])('executeMutation() with @match', (envi
564563
actor: {
565564
name: 'optimistic-actor-name',
566565
nameRenderer: {
567-
__id: 'client:4:nameRenderer(supported:["PlainUserNameRenderer","MarkdownUserNameRenderer"])',
566+
__id: 'client:4:nameRenderer(supported:"34hjiS")',
568567
__fragmentPropName: 'name',
569568
__fragments: {
570569
RelayModernEnvironmentExecuteMutationWithMatchTestMarkdownUserNameRenderer_name: {},
571570
},
572571
__fragmentOwner: operation.request,
573-
__isWithinUnmatchedTypeRefinement: false,
574572
__module_component: 'MarkdownUserNameRenderer.react',
575573
},
576574
},
@@ -620,13 +618,12 @@ describe.each(['RelayModernEnvironment'])('executeMutation() with @match', (envi
620618
actor: {
621619
name: 'optimistic-actor-name',
622620
nameRenderer: {
623-
__id: 'client:4:nameRenderer(supported:["PlainUserNameRenderer","MarkdownUserNameRenderer"])',
621+
__id: 'client:4:nameRenderer(supported:"34hjiS")',
624622
__fragmentPropName: 'name',
625623
__fragments: {
626624
RelayModernEnvironmentExecuteMutationWithMatchTestMarkdownUserNameRenderer_name: {},
627625
},
628626
__fragmentOwner: operation.request,
629-
__isWithinUnmatchedTypeRefinement: false,
630627
__module_component: 'MarkdownUserNameRenderer.react',
631628
},
632629
},
@@ -705,13 +702,12 @@ describe.each(['RelayModernEnvironment'])('executeMutation() with @match', (envi
705702
actor: {
706703
name: 'actor-name',
707704
nameRenderer: {
708-
__id: 'client:4:nameRenderer(supported:["PlainUserNameRenderer","MarkdownUserNameRenderer"])',
705+
__id: 'client:4:nameRenderer(supported:"34hjiS")',
709706
__fragmentPropName: 'name',
710707
__fragments: {
711708
RelayModernEnvironmentExecuteMutationWithMatchTestMarkdownUserNameRenderer_name: {},
712709
},
713710
__fragmentOwner: operation.request,
714-
__isWithinUnmatchedTypeRefinement: false,
715711
__module_component: 'MarkdownUserNameRenderer.react',
716712
},
717713
},

packages/relay-offline/package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,15 @@
4949
"tslib": "^1.11.1"
5050
},
5151
"peerDependencies": {
52-
"relay-runtime": "^13.0.0"
52+
"relay-runtime": "^20.1.1"
5353
},
5454
"devDependencies": {
5555
"@babel/runtime": "7.12.5",
56-
"@types/relay-runtime": "^13.0.0",
57-
"relay-runtime": "^13.0.0",
58-
"relay-compiler": "^13.0.0",
59-
"relay-test-utils-internal": "^13.0.0",
60-
"relay-test-utils": "^13.0.0",
56+
"@types/relay-runtime": "19.0.2",
57+
"relay-runtime": "^20.1.1",
58+
"relay-compiler": "^20.1.1",
59+
"relay-test-utils-internal": "^20.1.1",
60+
"relay-test-utils": "^20.1.1",
6161
"ts-relay-plugin": "1.0.1"
6262
},
6363
"relay": {

packages/relay-store/__tests__/Store-relay-original-test.ts

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -196,10 +196,10 @@ const UserEmailQuery = graphql`
196196
},
197197
},
198198
seenRecords: new Set(['4', 'client:1']),
199-
relayResolverErrors: [],
199+
missingLiveResolverFields: [],
200200
missingClientEdges: null,
201201
isMissingData: false,
202-
missingRequiredFields: null,
202+
fieldErrors: null,
203203
});
204204
for (const id in snapshot.seenRecords) {
205205
if (snapshot.seenRecords.hasOwnProperty(id)) {
@@ -245,15 +245,14 @@ const UserEmailQuery = graphql`
245245
},
246246

247247
__id: '4',
248-
__isWithinUnmatchedTypeRefinement: false,
249248
__fragments: { StoreRelayOriginalTestChildFragment: {} },
250249
__fragmentOwner: owner.request,
251250
},
252251
seenRecords: new Set(['4', 'client:1']),
253-
relayResolverErrors: [],
254252
missingClientEdges: null,
255253
isMissingData: false,
256-
missingRequiredFields: null,
254+
fieldErrors: null,
255+
missingLiveResolverFields: [],
257256
});
258257
expect(snapshot.data.__fragmentOwner).toBe(owner.request); // expect(snapshot.data?.__fragmentOwner).toBe(owner.request);
259258
for (const id in snapshot.seenRecords) {
@@ -301,10 +300,10 @@ const UserEmailQuery = graphql`
301300
},
302301
},
303302
seenRecords: new Set(['4', 'client:2']),
304-
relayResolverErrors: [],
305303
missingClientEdges: null,
306304
isMissingData: false,
307-
missingRequiredFields: null,
305+
fieldErrors: null,
306+
missingLiveResolverFields: [],
308307
});
309308
});
310309
});
@@ -513,10 +512,9 @@ const UserEmailQuery = graphql`
513512
expect(callback.mock.calls.length).toBe(1);
514513
expect(callback.mock.calls[0][0]).toEqual({
515514
...snapshot,
516-
relayResolverErrors: [],
515+
fieldErrors: null,
517516
missingClientEdges: null,
518517
isMissingData: false,
519-
missingRequiredFields: null,
520518
data: {
521519
name: 'Zuck',
522520
profilePicture: {
@@ -558,10 +556,22 @@ const UserEmailQuery = graphql`
558556
name: 'Joe',
559557
profilePicture: undefined,
560558
},
561-
relayResolverErrors: [],
559+
fieldErrors: [
560+
{
561+
owner: 'StoreRelayOriginalTestUserEmailFragment',
562+
kind: 'missing_expected_data.log',
563+
fieldPath: 'profilePicture',
564+
},
565+
{
566+
owner: 'StoreRelayOriginalTestUserEmailFragment',
567+
kind: 'missing_expected_data.log',
568+
fieldPath: 'emailAddresses',
569+
},
570+
],
571+
missingLiveResolverFields: [],
562572
missingClientEdges: null,
563573
isMissingData: true,
564-
seenRecords: new Set(['842472']),
574+
seenRecords: new Set(Object.keys(nextSource.toJSON())),
565575
});
566576
});
567577

@@ -598,9 +608,20 @@ const UserEmailQuery = graphql`
598608
name: 'Joe',
599609
profilePicture: undefined,
600610
},
601-
relayResolverErrors: [],
602611
missingClientEdges: null,
603612
isMissingData: true,
613+
fieldErrors: [
614+
{
615+
owner: 'StoreRelayOriginalTestUserEmailFragment',
616+
kind: 'missing_expected_data.log',
617+
fieldPath: 'profilePicture',
618+
},
619+
{
620+
owner: 'StoreRelayOriginalTestUserEmailFragment',
621+
kind: 'missing_expected_data.log',
622+
fieldPath: 'emailAddresses',
623+
},
624+
],
604625
seenRecords: new Set(['842472']),
605626
});
606627
});

packages/relay-store/package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,15 @@
5252
"tslib": "^1.11.1"
5353
},
5454
"peerDependencies": {
55-
"relay-runtime": "^13.0.0"
55+
"relay-runtime": "^20.1.1"
5656
},
5757
"devDependencies": {
5858
"@babel/runtime": "7.12.5",
59-
"@types/relay-runtime": "^13.0.0",
60-
"relay-runtime": "^13.0.0",
61-
"relay-compiler": "^13.0.0",
62-
"relay-test-utils-internal": "^13.0.0",
63-
"relay-test-utils": "^13.0.0",
59+
"@types/relay-runtime": "19.0.2",
60+
"relay-runtime": "^20.1.1",
61+
"relay-compiler": "^20.1.1",
62+
"relay-test-utils-internal": "^20.1.1",
63+
"relay-test-utils": "^20.1.1",
6464
"ts-relay-plugin": "1.0.1"
6565
},
6666
"gitHead": "07b6de318f2db9d94622d54be6c60940871f3629"

packages/relay-store/src/Store.ts

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { Cache, CacheOptions } from '@wora/cache-persist';
77
import { RecordSource } from './RecordSource';
88
import * as DataChecker from 'relay-runtime/lib/store/DataChecker';
99
import { GetDataID } from 'relay-runtime/lib/store/RelayResponseNormalizer';
10-
import { assertInternalActorIndentifier } from 'relay-runtime/lib/multi-actor-environment/ActorIdentifier';
10+
import { assertInternalActorIdentifier } from 'relay-runtime/lib/multi-actor-environment/ActorIdentifier';
1111

1212
const INTERNAL_ACTOR_IDENTIFIER_DO_NOT_USE = 'INTERNAL_ACTOR_IDENTIFIER_DO_NOT_USE';
1313

@@ -46,6 +46,9 @@ export class Store extends RelayModernStore {
4646
(this._cache as any).values = (): any => {
4747
return Object.values(this._cache.getState());
4848
};
49+
(this._cache as any).entries = (): any => {
50+
return Object.entries(this._cache.getState());
51+
};
4952
(this as any)._roots = this._cache;
5053
}
5154

@@ -138,15 +141,7 @@ export class Store extends RelayModernStore {
138141
if ((this as any)._optimisticSource != null || !this.checkGC()) {
139142
return;
140143
}
141-
if ((this as any)._gcHoldCounter > 0) {
142-
(this as any)._shouldScheduleGC = true;
143-
return;
144-
}
145-
if ((this as any)._gcRun) {
146-
return;
147-
}
148-
(this as any)._gcRun = (this as any)._collect();
149-
(this as any)._gcScheduler((this as any)._gcStep);
144+
super.scheduleGC();
150145
}
151146

152147
private isCurrent(fetchTime: number, ttl: number): boolean {
@@ -157,6 +152,10 @@ export class Store extends RelayModernStore {
157152
const selector = operation.root;
158153
const source = (this as any)._getMutableRecordSource();
159154
const globalInvalidationEpoch = (this as any)._globalInvalidationEpoch;
155+
const useExecTimeResolvers =
156+
operation.request.node.operation.use_exec_time_resolvers ??
157+
operation.request.node.operation.exec_time_resolvers_enabled_provider?.get() === true ??
158+
false;
160159

161160
const rootEntry = this._cache.get(operation.request.identifier);
162161
const operationLastWrittenAt = rootEntry != null ? rootEntry.epoch : null;
@@ -177,13 +176,13 @@ export class Store extends RelayModernStore {
177176
const getSourceForActor =
178177
(options as any)?.getSourceForActor ??
179178
((actorIdentifier): any => {
180-
assertInternalActorIndentifier(actorIdentifier);
179+
assertInternalActorIdentifier(actorIdentifier);
181180
return source;
182181
});
183182
const getTargetForActor =
184183
(options as any)?.getTargetForActor ??
185184
((actorIdentifier): any => {
186-
assertInternalActorIndentifier(actorIdentifier);
185+
assertInternalActorIdentifier(actorIdentifier);
187186
return source;
188187
});
189188
const handlers = options?.handlers ?? [];
@@ -196,6 +195,8 @@ export class Store extends RelayModernStore {
196195
(this as any)._operationLoader,
197196
(this as any)._getDataID,
198197
(this as any)._shouldProcessClientComponents,
198+
(this as any).__log,
199+
useExecTimeResolvers,
199200
);
200201

201202
return getAvailabilityStatus(

0 commit comments

Comments
 (0)