Skip to content

Commit

Permalink
Merge branch 'main' into docs-update
Browse files Browse the repository at this point in the history
  • Loading branch information
thetnaingtn authored Oct 9, 2023
2 parents 2b56e6f + 3e881f1 commit f4cba1e
Show file tree
Hide file tree
Showing 13 changed files with 191 additions and 73 deletions.
2 changes: 1 addition & 1 deletion .api-reports/api-report-utilities_globals.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ type WrappedInvariant = {

// Warnings were encountered during analysis:
//
// src/utilities/globals/invariantWrappers.ts:58:3 - (ae-forgotten-export) The symbol "LogFunction" needs to be exported by the entry point index.d.ts
// src/utilities/globals/invariantWrappers.ts:62:3 - (ae-forgotten-export) The symbol "LogFunction" needs to be exported by the entry point index.d.ts

// (No @packageDocumentation comment for this package)

Expand Down
5 changes: 0 additions & 5 deletions .changeset/early-snakes-cheer.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/hungry-vans-walk.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/pretty-readers-lick.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/short-owls-breathe.md

This file was deleted.

10 changes: 5 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:

Lint:
docker:
- image: cimg/node:20.6.1
- image: cimg/node:20.7.0
steps:
- checkout
- run: npm version
Expand All @@ -21,15 +21,15 @@ jobs:

Formatting:
docker:
- image: cimg/node:20.6.1
- image: cimg/node:20.7.0
steps:
- checkout
- run: npm ci
- run: npm run check:format

Tests:
docker:
- image: cimg/node:20.6.1
- image: cimg/node:20.7.0
steps:
- checkout
- run: npm run ci:precheck
Expand All @@ -47,7 +47,7 @@ jobs:

BuildTarball:
docker:
- image: cimg/node:20.6.1
- image: cimg/node:20.7.0
steps:
- checkout
- run: npm run ci:precheck
Expand All @@ -64,7 +64,7 @@ jobs:
framework:
type: string
docker:
- image: cimg/node:20.6.1
- image: cimg/node:20.7.0
steps:
- checkout
- attach_workspace:
Expand Down
4 changes: 2 additions & 2 deletions .size-limit.cjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const checks = [
{
path: "dist/apollo-client.min.cjs",
limit: "37914",
limit: "37940",
},
{
path: "dist/main.cjs",
Expand All @@ -10,7 +10,7 @@ const checks = [
{
path: "dist/index.js",
import: "{ ApolloClient, InMemoryCache, HttpLink }",
limit: "31947",
limit: "31970",
},
...[
"ApolloProvider",
Expand Down
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# @apollo/client

## 3.8.5

### Patch Changes

- [#11266](https://github.com/apollographql/apollo-client/pull/11266) [`5192cf6e1`](https://github.com/apollographql/apollo-client/commit/5192cf6e1e958080bcae09e5967fa6851bd3a78c) Thanks [@phryneas](https://github.com/phryneas)! - Fixes argument handling for invariant log messages.

- [#11235](https://github.com/apollographql/apollo-client/pull/11235) [`6cddaaf65`](https://github.com/apollographql/apollo-client/commit/6cddaaf6543f5c0b1fb04ba47480fb393ba10de7) Thanks [@phryneas](https://github.com/phryneas)! - Fix nextFetchPolicy behaviour with transformed documents by keeping `options` reference stable when passing it through QueryManager.

- [#11252](https://github.com/apollographql/apollo-client/pull/11252) [`327a2abbd`](https://github.com/apollographql/apollo-client/commit/327a2abbd5db87ca27f2ffd1d2f8dccd75868a58) Thanks [@phryneas](https://github.com/phryneas)! - Fixes a race condition in asyncMap that caused issues in React Native when errors were returned in the response payload along with a data property that was null.

- [#11229](https://github.com/apollographql/apollo-client/pull/11229) [`c372bad4e`](https://github.com/apollographql/apollo-client/commit/c372bad4ebd01a4f2e772cd76e873143bf043fe6) Thanks [@phryneas](https://github.com/phryneas)! - Remove (already throwing) SuspenseCache export that should have been removed in 3.8.

- [#11267](https://github.com/apollographql/apollo-client/pull/11267) [`bc055e068`](https://github.com/apollographql/apollo-client/commit/bc055e0683e87b9445e321f73857f4a91b20a9ce) Thanks [@phryneas](https://github.com/phryneas)! - Remove some dead code.

## 3.8.4

### Patch Changes
Expand Down
46 changes: 23 additions & 23 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@apollo/client",
"version": "3.8.4",
"version": "3.8.5",
"description": "A fully-featured caching GraphQL client.",
"private": true,
"keywords": [
Expand Down Expand Up @@ -108,7 +108,7 @@
"@changesets/changelog-github": "0.4.8",
"@changesets/cli": "2.26.2",
"@graphql-tools/schema": "10.0.0",
"@microsoft/api-extractor": "7.37.0",
"@microsoft/api-extractor": "7.38.0",
"@rollup/plugin-node-resolve": "11.2.1",
"@size-limit/esbuild-why": "8.2.6",
"@size-limit/preset-small-lib": "8.2.6",
Expand Down
2 changes: 1 addition & 1 deletion src/dev/loadErrorMessageHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export function loadErrorMessageHandler(...errorCodes: ErrorCodes[]) {
message = definition.message;
}
return args.reduce<string>(
(msg, arg) => msg.replace("%s", String(arg)),
(msg, arg) => msg.replace(/%[sdfo]/, String(arg)),
String(message)
);
}
Expand Down
101 changes: 101 additions & 0 deletions src/utilities/globals/__tests__/invariantWrappers.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
import { loadErrorMessageHandler } from "../../../dev";
import { spyOnConsole, withCleanup } from "../../../testing/internal";
import {
ApolloErrorMessageHandler,
InvariantError,
invariant,
} from "../invariantWrappers";

function disableErrorMessageHandler() {
const original = window[ApolloErrorMessageHandler];
delete window[ApolloErrorMessageHandler];
return withCleanup({ original }, ({ original }) => {
window[ApolloErrorMessageHandler] = original;
});
}

function mockErrorMessageHandler() {
const original = window[ApolloErrorMessageHandler];
delete window[ApolloErrorMessageHandler];

loadErrorMessageHandler({
5: { file: "foo", message: "Replacing %s, %d, %f, %o" },
});

return withCleanup({ original }, ({ original }) => {
window[ApolloErrorMessageHandler] = original;
});
}

test("base invariant(false, 5, ...), no handlers", () => {
using _ = disableErrorMessageHandler();
expect(() => {
invariant(false, 5, "string", 1, 1.1, { a: 1 });
}).toThrow(
new InvariantError(
"An error occurred! For more details, see the full error text at https://go.apollo.dev/c/err#" +
encodeURIComponent(
JSON.stringify({
version: "local",
message: 5,
args: [
"string",
"1",
"1.1",
JSON.stringify({ a: 1 }, undefined, 2),
],
})
)
)
);
});

test("base invariant(false, 5, ...), handlers in place", () => {
using _ = mockErrorMessageHandler();
expect(() => {
invariant(false, 5, "string", 1, 1.1, { a: 1 });
}).toThrow(new InvariantError('Replacing string, 1, 1.1, {\n "a": 1\n}'));
});

test("base invariant(false, undefined), no handlers", () => {
using _ = disableErrorMessageHandler();
expect(() => {
invariant(false);
}).toThrow(new InvariantError("Invariant Violation"));
});

test("base invariant(false, undefined), handlers in place", () => {
using _ = mockErrorMessageHandler();
expect(() => {
invariant(false);
}).toThrow(new InvariantError("Invariant Violation"));
});

test("invariant.log(5, ...), no handlers", () => {
using _ = disableErrorMessageHandler();
using consoleSpy = spyOnConsole("log");
invariant.log(5, "string", 1, 1.1, { a: 1 });
expect(consoleSpy.log).toHaveBeenCalledWith(
"An error occurred! For more details, see the full error text at https://go.apollo.dev/c/err#" +
encodeURIComponent(
JSON.stringify({
version: "local",
message: 5,
args: ["string", "1", "1.1", JSON.stringify({ a: 1 }, undefined, 2)],
})
)
);
});

test("invariant.log(5, ...), with handlers", () => {
using _ = mockErrorMessageHandler();
using consoleSpy = spyOnConsole("log");
invariant.log(5, "string", 1, 1.1, { a: 1 });
expect(consoleSpy.log).toHaveBeenCalledWith(
"Replacing %s, %d, %f, %o",
"string",
1,
1.1,
{ a: 1 }
);
});
Loading

0 comments on commit f4cba1e

Please sign in to comment.