Skip to content

Commit

Permalink
Merge branch 'main' into feat/replace-next-import-with-redwood
Browse files Browse the repository at this point in the history
  • Loading branch information
phryneas authored Sep 20, 2023
2 parents 5141fa5 + 07583cb commit 399852f
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,15 @@ on:
paths:
- "package/**"
- "integration-test/**"
pull_request:
paths:
- "package/**"
- "integration-test/**"
workflow_dispatch:
jobs:
test:
name: Run unit tests
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -18,6 +24,7 @@ jobs:
- run: yarn workspace @apollo/experimental-nextjs-app-support run test > $GITHUB_STEP_SUMMARY
tests_playwright:
name: Run Playwright tests
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand Down
3 changes: 2 additions & 1 deletion package/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@apollo/experimental-nextjs-app-support",
"version": "0.4.1",
"version": "0.4.3",
"repository": {
"url": "git+https://github.com/apollographql/apollo-client-nextjs"
},
Expand Down Expand Up @@ -64,6 +64,7 @@
"react": "^18"
},
"dependencies": {
"server-only": "^0.0.1",
"superjson": "^1.12.2",
"ts-invariant": "^0.10.3"
}
Expand Down
13 changes: 2 additions & 11 deletions package/src/rsc/registerApolloClient.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,9 @@
import "server-only";

import type { ApolloClient } from "@apollo/client";
import * as React from "react";

function assertRSC(
reactImport: typeof import("react")
): asserts reactImport is typeof import("react") & { cache<T>(x: () => T): T } {
if ("createContext" in React) {
throw new Error(
"`registerApolloClient` should only be used in a React Server Component context - in Client Components, use the `ApolloNextAppProvider`!"
);
}
}

export function registerApolloClient(makeClient: () => ApolloClient<any>) {
assertRSC(React);
const getClient = React.cache(makeClient);
return {
getClient,
Expand Down
4 changes: 2 additions & 2 deletions package/src/ssr/NextSSRApolloClient.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ export class NextSSRApolloClient<
);
});

promise.finally(cleanup);
byVariables.set(
varJson,
(observable = new Observable<FetchResult>((observer) => {
Expand All @@ -134,8 +135,7 @@ export class NextSSRApolloClient<
})
.catch((err) => {
observer.error(err);
})
.finally(cleanup);
});
}))
);

Expand Down
1 change: 1 addition & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ __metadata:
next: ^13.4.4
react: ^18.2.0
rimraf: ^5.0.0
server-only: ^0.0.1
superjson: ^1.12.2
ts-invariant: ^0.10.3
ts-node: ^10.9.1
Expand Down

0 comments on commit 399852f

Please sign in to comment.