Skip to content

Commit a3c87e5

Browse files
Attempt at upgrading
Signed-off-by: Steve Coffman <[email protected]>
1 parent 62420c4 commit a3c87e5

File tree

1 file changed

+114
-13
lines changed

1 file changed

+114
-13
lines changed

integration/src/__test__/integration.spec.ts

Lines changed: 114 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
11
import { afterAll, describe, expect, it } from "vitest";
22

33
import fetch from 'cross-fetch';
4-
import {
5-
ApolloClient,
6-
ApolloLink,
7-
FetchResult,
8-
InMemoryCache,
9-
NormalizedCacheObject,
10-
Observable,
11-
Operation,
12-
} from '@apollo/client/core';
4+
import { ApolloClient, ApolloLink, InMemoryCache, NormalizedCacheObject, Observable } from "@apollo/client";
5+
import { Defer20220824Handler } from "@apollo/client/incremental";
6+
import { LocalState } from "@apollo/client/local-state";
137
import { HttpLink } from '@apollo/client/link/http';
148

159
import { print } from "graphql";
@@ -43,7 +37,7 @@ import { join } from "path";
4337

4438
const uri = process.env.VITE_SERVER_URL || "http://localhost:8080/query";
4539

46-
function test(client: ApolloClient<NormalizedCacheObject>) {
40+
function test(client: ApolloClient) {
4741
describe("Json", () => {
4842
it("should follow json escaping rules", async () => {
4943
const res = await client.query({
@@ -238,8 +232,8 @@ function test(client: ApolloClient<NormalizedCacheObject>) {
238232

239233
describe("HTTP client", () => {
240234
const client = new ApolloClient({
241-
uri: uri,
242235
cache: new InMemoryCache(),
236+
243237
defaultOptions: {
244238
watchQuery: {
245239
fetchPolicy: "network-only",
@@ -250,6 +244,24 @@ describe("HTTP client", () => {
250244
errorPolicy: "all",
251245
},
252246
},
247+
248+
link: new HttpLink({
249+
uri: uri
250+
}),
251+
252+
/*
253+
Inserted by Apollo Client 3->4 migration codemod.
254+
If you are not using the `@client` directive in your application,
255+
you can safely remove this option.
256+
*/
257+
localState: new LocalState({}),
258+
259+
/*
260+
Inserted by Apollo Client 3->4 migration codemod.
261+
If you are not using the `@defer` directive in your application,
262+
you can safely remove this option.
263+
*/
264+
incrementalHandler: new Defer20220824Handler()
253265
});
254266

255267
test(client);
@@ -293,7 +305,9 @@ describe("Websocket client", () => {
293305
webSocketImpl: WebSocket,
294306
})
295307
),
308+
296309
cache: new InMemoryCache(),
310+
297311
defaultOptions: {
298312
watchQuery: {
299313
fetchPolicy: "network-only",
@@ -304,6 +318,20 @@ describe("Websocket client", () => {
304318
errorPolicy: "all",
305319
},
306320
},
321+
322+
/*
323+
Inserted by Apollo Client 3->4 migration codemod.
324+
If you are not using the `@client` directive in your application,
325+
you can safely remove this option.
326+
*/
327+
localState: new LocalState({}),
328+
329+
/*
330+
Inserted by Apollo Client 3->4 migration codemod.
331+
If you are not using the `@defer` directive in your application,
332+
you can safely remove this option.
333+
*/
334+
incrementalHandler: new Defer20220824Handler()
307335
});
308336

309337
test(client);
@@ -322,9 +350,9 @@ describe("SSE client", () => {
322350
this.client = createClientSSE(options);
323351
}
324352

325-
public request(operation: Operation): Observable<FetchResult> {
353+
public request(operation: ApolloLink.Operation): Observable<ApolloLink.Result> {
326354
return new Observable((sink) => {
327-
return this.client.subscribe<FetchResult>(
355+
return this.client.subscribe<ApolloLink.Result>(
328356
{ ...operation, query: print(operation.query) },
329357
{
330358
next: sink.next.bind(sink),
@@ -340,7 +368,9 @@ describe("SSE client", () => {
340368
link: new SSELink({
341369
url: uri,
342370
}),
371+
343372
cache: new InMemoryCache(),
373+
344374
defaultOptions: {
345375
watchQuery: {
346376
fetchPolicy: "network-only",
@@ -351,6 +381,20 @@ describe("SSE client", () => {
351381
errorPolicy: "all",
352382
},
353383
},
384+
385+
/*
386+
Inserted by Apollo Client 3->4 migration codemod.
387+
If you are not using the `@client` directive in your application,
388+
you can safely remove this option.
389+
*/
390+
localState: new LocalState({}),
391+
392+
/*
393+
Inserted by Apollo Client 3->4 migration codemod.
394+
If you are not using the `@defer` directive in your application,
395+
you can safely remove this option.
396+
*/
397+
incrementalHandler: new Defer20220824Handler()
354398
});
355399

356400
test(client);
@@ -415,3 +459,60 @@ describe("URQL SSE client", () => {
415459
});
416460
});
417461
});
462+
463+
/*
464+
Start: Inserted by Apollo Client 3->4 migration codemod.
465+
Copy the contents of this block into a `.d.ts` file in your project to enable correct response types in your custom links.
466+
If you do not use the `@defer` directive in your application, you can safely remove this block.
467+
*/
468+
469+
470+
import "@apollo/client";
471+
import { Defer20220824Handler } from "@apollo/client/incremental";
472+
473+
declare module "@apollo/client" {
474+
export interface TypeOverrides extends Defer20220824Handler.TypeOverrides {}
475+
}
476+
477+
/*
478+
End: Inserted by Apollo Client 3->4 migration codemod.
479+
*/
480+
481+
482+
/*
483+
Start: Inserted by Apollo Client 3->4 migration codemod.
484+
Copy the contents of this block into a `.d.ts` file in your project to enable correct response types in your custom links.
485+
If you do not use the `@defer` directive in your application, you can safely remove this block.
486+
*/
487+
488+
489+
import "@apollo/client";
490+
import { Defer20220824Handler } from "@apollo/client/incremental";
491+
492+
declare module "@apollo/client" {
493+
export interface TypeOverrides extends Defer20220824Handler.TypeOverrides {}
494+
}
495+
496+
/*
497+
End: Inserted by Apollo Client 3->4 migration codemod.
498+
*/
499+
500+
501+
/*
502+
Start: Inserted by Apollo Client 3->4 migration codemod.
503+
Copy the contents of this block into a `.d.ts` file in your project to enable correct response types in your custom links.
504+
If you do not use the `@defer` directive in your application, you can safely remove this block.
505+
*/
506+
507+
508+
import "@apollo/client";
509+
import { Defer20220824Handler } from "@apollo/client/incremental";
510+
511+
declare module "@apollo/client" {
512+
export interface TypeOverrides extends Defer20220824Handler.TypeOverrides {}
513+
}
514+
515+
/*
516+
End: Inserted by Apollo Client 3->4 migration codemod.
517+
*/
518+

0 commit comments

Comments
 (0)