From 7414a6bd5451c16bd57319fb3bee304572c40806 Mon Sep 17 00:00:00 2001 From: Lenz Weber-Tronic Date: Wed, 18 Dec 2024 15:35:46 +0100 Subject: [PATCH] move `IncrementalSchemaLink` and others to `shared` --- integration-test/nextjs/package.json | 1 + integration-test/nextjs/src/app/cc/ApolloWrapper.tsx | 4 ++-- integration-test/nextjs/src/app/graphql/route.ts | 2 +- integration-test/nextjs/src/app/rsc/client.ts | 4 ++-- .../defer-queryRef-useReadQuery/ClientChild.tsx | 2 +- .../PreloadQuery/defer-queryRef-useReadQuery/page.tsx | 2 +- .../dynamic/PreloadQuery/queryRef-refTest/RefTestChild.tsx | 2 +- .../app/rsc/dynamic/PreloadQuery/queryRef-refTest/page.tsx | 2 +- .../PreloadQuery/queryRef-useReadQuery/ClientChild.tsx | 2 +- .../rsc/dynamic/PreloadQuery/queryRef-useReadQuery/page.tsx | 2 +- .../dynamic/PreloadQuery/useSuspenseQuery/ClientChild.tsx | 2 +- .../app/rsc/dynamic/PreloadQuery/useSuspenseQuery/page.tsx | 2 +- integration-test/nextjs/tsconfig.json | 2 +- .../src/app/graphql => shared}/IncrementalSchemaLink.ts | 0 integration-test/shared/package.json | 6 +++++- .../dynamic/PreloadQuery/shared.tsx => shared/queries.ts} | 2 +- .../{nextjs/src/app/graphql => shared}/schema.ts | 0 integration-test/yarn.lock | 6 +++++- 18 files changed, 26 insertions(+), 17 deletions(-) rename integration-test/{nextjs/src/app/graphql => shared}/IncrementalSchemaLink.ts (100%) rename integration-test/{nextjs/src/app/rsc/dynamic/PreloadQuery/shared.tsx => shared/queries.ts} (93%) rename integration-test/{nextjs/src/app/graphql => shared}/schema.ts (100%) diff --git a/integration-test/nextjs/package.json b/integration-test/nextjs/package.json index 904f0f43..7a0036f9 100644 --- a/integration-test/nextjs/package.json +++ b/integration-test/nextjs/package.json @@ -15,6 +15,7 @@ "@apollo/server": "^4.11.2", "@as-integrations/next": "^3.2.0", "@graphql-tools/schema": "^10.0.0", + "@integration-test/shared": "workspace:^", "@types/node": "20.3.1", "@types/react": "^19.0.0", "@types/react-dom": "^19.0.0", diff --git a/integration-test/nextjs/src/app/cc/ApolloWrapper.tsx b/integration-test/nextjs/src/app/cc/ApolloWrapper.tsx index 04be669d..c39ee232 100644 --- a/integration-test/nextjs/src/app/cc/ApolloWrapper.tsx +++ b/integration-test/nextjs/src/app/cc/ApolloWrapper.tsx @@ -10,11 +10,11 @@ import { import { loadErrorMessages, loadDevMessages } from "@apollo/client/dev"; import { setVerbosity } from "ts-invariant"; import { delayLink } from "@/shared/delayLink"; -import { schema } from "../graphql/schema"; +import { schema } from "@integration-test/shared/schema"; import { useSSROnlySecret } from "ssr-only-secrets"; import { errorLink } from "../../shared/errorLink"; -import { IncrementalSchemaLink } from "../graphql/IncrementalSchemaLink"; +import { IncrementalSchemaLink } from "@integration-test/shared/IncrementalSchemaLink"; setVerbosity("debug"); loadDevMessages(); diff --git a/integration-test/nextjs/src/app/graphql/route.ts b/integration-test/nextjs/src/app/graphql/route.ts index c977ce7a..5c393abf 100644 --- a/integration-test/nextjs/src/app/graphql/route.ts +++ b/integration-test/nextjs/src/app/graphql/route.ts @@ -1,6 +1,6 @@ import { startServerAndCreateNextHandler } from "@as-integrations/next"; import { ApolloServer } from "@apollo/server"; -import { schema } from "./schema"; +import { schema } from "@integration-test/shared/schema"; const server = new ApolloServer({ schema, diff --git a/integration-test/nextjs/src/app/rsc/client.ts b/integration-test/nextjs/src/app/rsc/client.ts index 63d863db..1e90da7d 100644 --- a/integration-test/nextjs/src/app/rsc/client.ts +++ b/integration-test/nextjs/src/app/rsc/client.ts @@ -9,8 +9,8 @@ import { setVerbosity } from "ts-invariant"; import { delayLink } from "@/shared/delayLink"; import { errorLink } from "@/shared/errorLink"; -import { schema } from "../graphql/schema"; -import { IncrementalSchemaLink } from "../graphql/IncrementalSchemaLink"; +import { schema } from "@integration-test/shared/schema"; +import { IncrementalSchemaLink } from "@integration-test/shared/IncrementalSchemaLink"; setVerbosity("debug"); loadDevMessages(); diff --git a/integration-test/nextjs/src/app/rsc/dynamic/PreloadQuery/defer-queryRef-useReadQuery/ClientChild.tsx b/integration-test/nextjs/src/app/rsc/dynamic/PreloadQuery/defer-queryRef-useReadQuery/ClientChild.tsx index 0655eed3..ebde96e5 100644 --- a/integration-test/nextjs/src/app/rsc/dynamic/PreloadQuery/defer-queryRef-useReadQuery/ClientChild.tsx +++ b/integration-test/nextjs/src/app/rsc/dynamic/PreloadQuery/defer-queryRef-useReadQuery/ClientChild.tsx @@ -5,7 +5,7 @@ import { useQueryRefHandlers, useReadQuery, } from "@apollo/client"; -import { DeferredDynamicProductResult } from "../shared"; +import { DeferredDynamicProductResult } from "@integration-test/shared/queries"; import { TransportedQueryRef } from "@apollo/experimental-nextjs-app-support"; import { useTransition } from "react"; diff --git a/integration-test/nextjs/src/app/rsc/dynamic/PreloadQuery/defer-queryRef-useReadQuery/page.tsx b/integration-test/nextjs/src/app/rsc/dynamic/PreloadQuery/defer-queryRef-useReadQuery/page.tsx index 1ca54c0e..3d538bdf 100644 --- a/integration-test/nextjs/src/app/rsc/dynamic/PreloadQuery/defer-queryRef-useReadQuery/page.tsx +++ b/integration-test/nextjs/src/app/rsc/dynamic/PreloadQuery/defer-queryRef-useReadQuery/page.tsx @@ -1,6 +1,6 @@ import { ApolloWrapper } from "@/app/cc/ApolloWrapper"; import { ClientChild } from "./ClientChild"; -import { DEFERRED_QUERY } from "../shared"; +import { DEFERRED_QUERY } from "@integration-test/shared/queries"; export const dynamic = "force-dynamic"; import { PreloadQuery } from "../../../client"; diff --git a/integration-test/nextjs/src/app/rsc/dynamic/PreloadQuery/queryRef-refTest/RefTestChild.tsx b/integration-test/nextjs/src/app/rsc/dynamic/PreloadQuery/queryRef-refTest/RefTestChild.tsx index 5f3707c0..37365db0 100644 --- a/integration-test/nextjs/src/app/rsc/dynamic/PreloadQuery/queryRef-refTest/RefTestChild.tsx +++ b/integration-test/nextjs/src/app/rsc/dynamic/PreloadQuery/queryRef-refTest/RefTestChild.tsx @@ -1,7 +1,7 @@ "use client"; import { QueryRef, useQueryRefHandlers } from "@apollo/client"; -import { DynamicProductResult } from "../shared"; +import { DynamicProductResult } from "@integration-test/shared/queries"; import { useEffect, useState } from "react"; import { InternalQueryReference, diff --git a/integration-test/nextjs/src/app/rsc/dynamic/PreloadQuery/queryRef-refTest/page.tsx b/integration-test/nextjs/src/app/rsc/dynamic/PreloadQuery/queryRef-refTest/page.tsx index 9315e936..0d933a78 100644 --- a/integration-test/nextjs/src/app/rsc/dynamic/PreloadQuery/queryRef-refTest/page.tsx +++ b/integration-test/nextjs/src/app/rsc/dynamic/PreloadQuery/queryRef-refTest/page.tsx @@ -1,4 +1,4 @@ -import { QUERY } from "../shared"; +import { QUERY } from "@integration-test/shared/queries"; import { Suspense } from "react"; import { PreloadQuery } from "@/app/rsc/client"; import { RefTestChild } from "./RefTestChild"; diff --git a/integration-test/nextjs/src/app/rsc/dynamic/PreloadQuery/queryRef-useReadQuery/ClientChild.tsx b/integration-test/nextjs/src/app/rsc/dynamic/PreloadQuery/queryRef-useReadQuery/ClientChild.tsx index 96ff036d..45281e26 100644 --- a/integration-test/nextjs/src/app/rsc/dynamic/PreloadQuery/queryRef-useReadQuery/ClientChild.tsx +++ b/integration-test/nextjs/src/app/rsc/dynamic/PreloadQuery/queryRef-useReadQuery/ClientChild.tsx @@ -1,7 +1,7 @@ "use client"; import { useQueryRefHandlers, useReadQuery } from "@apollo/client"; -import { DynamicProductResult } from "../shared"; +import { DynamicProductResult } from "@integration-test/shared/queries"; import { TransportedQueryRef } from "@apollo/experimental-nextjs-app-support"; export function ClientChild({ diff --git a/integration-test/nextjs/src/app/rsc/dynamic/PreloadQuery/queryRef-useReadQuery/page.tsx b/integration-test/nextjs/src/app/rsc/dynamic/PreloadQuery/queryRef-useReadQuery/page.tsx index c89e7fe4..51db0e3a 100644 --- a/integration-test/nextjs/src/app/rsc/dynamic/PreloadQuery/queryRef-useReadQuery/page.tsx +++ b/integration-test/nextjs/src/app/rsc/dynamic/PreloadQuery/queryRef-useReadQuery/page.tsx @@ -1,6 +1,6 @@ import { ApolloWrapper } from "@/app/cc/ApolloWrapper"; import { ClientChild } from "./ClientChild"; -import { QUERY } from "../shared"; +import { QUERY } from "@integration-test/shared/queries"; export const dynamic = "force-dynamic"; import { PreloadQuery } from "../../../client"; diff --git a/integration-test/nextjs/src/app/rsc/dynamic/PreloadQuery/useSuspenseQuery/ClientChild.tsx b/integration-test/nextjs/src/app/rsc/dynamic/PreloadQuery/useSuspenseQuery/ClientChild.tsx index 192a073c..fe84a075 100644 --- a/integration-test/nextjs/src/app/rsc/dynamic/PreloadQuery/useSuspenseQuery/ClientChild.tsx +++ b/integration-test/nextjs/src/app/rsc/dynamic/PreloadQuery/useSuspenseQuery/ClientChild.tsx @@ -1,7 +1,7 @@ "use client"; import { useSuspenseQuery } from "@apollo/client"; -import { QUERY } from "../shared"; +import { QUERY } from "@integration-test/shared/queries"; export function ClientChild() { const { data } = useSuspenseQuery(QUERY); diff --git a/integration-test/nextjs/src/app/rsc/dynamic/PreloadQuery/useSuspenseQuery/page.tsx b/integration-test/nextjs/src/app/rsc/dynamic/PreloadQuery/useSuspenseQuery/page.tsx index 6c928f40..06d5a236 100644 --- a/integration-test/nextjs/src/app/rsc/dynamic/PreloadQuery/useSuspenseQuery/page.tsx +++ b/integration-test/nextjs/src/app/rsc/dynamic/PreloadQuery/useSuspenseQuery/page.tsx @@ -1,6 +1,6 @@ import { ApolloWrapper } from "@/app/cc/ApolloWrapper"; import { ClientChild } from "./ClientChild"; -import { QUERY } from "../shared"; +import { QUERY } from "@integration-test/shared/queries"; export const dynamic = "force-dynamic"; import { PreloadQuery } from "../../../client"; diff --git a/integration-test/nextjs/tsconfig.json b/integration-test/nextjs/tsconfig.json index 0c7555fa..a98b748c 100644 --- a/integration-test/nextjs/tsconfig.json +++ b/integration-test/nextjs/tsconfig.json @@ -23,6 +23,6 @@ "@/*": ["./src/*"] } }, - "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"], + "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts", "../shared/*.ts"], "exclude": ["node_modules"] } diff --git a/integration-test/nextjs/src/app/graphql/IncrementalSchemaLink.ts b/integration-test/shared/IncrementalSchemaLink.ts similarity index 100% rename from integration-test/nextjs/src/app/graphql/IncrementalSchemaLink.ts rename to integration-test/shared/IncrementalSchemaLink.ts diff --git a/integration-test/shared/package.json b/integration-test/shared/package.json index c7f01daa..8975b4a5 100644 --- a/integration-test/shared/package.json +++ b/integration-test/shared/package.json @@ -1,3 +1,7 @@ { - "name": "@integration-test/shared" + "name": "@integration-test/shared", + "peerDependencies": { + "@apollo/client": "*", + "graphql": "*" + } } diff --git a/integration-test/nextjs/src/app/rsc/dynamic/PreloadQuery/shared.tsx b/integration-test/shared/queries.ts similarity index 93% rename from integration-test/nextjs/src/app/rsc/dynamic/PreloadQuery/shared.tsx rename to integration-test/shared/queries.ts index f1b6a026..e3d73845 100644 --- a/integration-test/nextjs/src/app/rsc/dynamic/PreloadQuery/shared.tsx +++ b/integration-test/shared/queries.ts @@ -1,4 +1,4 @@ -import { TypedDocumentNode, gql } from "@apollo/client"; +import { TypedDocumentNode, gql } from "@apollo/client/index.js"; export interface DynamicProductResult { products: { diff --git a/integration-test/nextjs/src/app/graphql/schema.ts b/integration-test/shared/schema.ts similarity index 100% rename from integration-test/nextjs/src/app/graphql/schema.ts rename to integration-test/shared/schema.ts diff --git a/integration-test/yarn.lock b/integration-test/yarn.lock index c7a6460b..b87b9b23 100644 --- a/integration-test/yarn.lock +++ b/integration-test/yarn.lock @@ -2723,6 +2723,7 @@ __metadata: "@apollo/server": "npm:^4.11.2" "@as-integrations/next": "npm:^3.2.0" "@graphql-tools/schema": "npm:^10.0.0" + "@integration-test/shared": "workspace:^" "@playwright/test": "npm:^1.49.1" "@types/node": "npm:20.3.1" "@types/react": "npm:^19.0.0" @@ -2747,9 +2748,12 @@ __metadata: languageName: unknown linkType: soft -"@integration-test/shared@workspace:shared": +"@integration-test/shared@workspace:^, @integration-test/shared@workspace:shared": version: 0.0.0-use.local resolution: "@integration-test/shared@workspace:shared" + peerDependencies: + "@apollo/client": "*" + graphql: "*" languageName: unknown linkType: soft