mirror of
https://github.com/expo/dev-plugins.git
synced 2026-11-15 17:31:28 -10:00
## Summary Fixes #57 — the `@dev-plugins/apollo-client` plugin throws / stops reporting queries and mutations under Apollo Client v4. Two internals the plugin relied on changed shape in v4: - `getOperationName` moved from `@apollo/client/utilities` to `@apollo/client/utilities/internal` (this is what the linked issue comment flagged). - The private `client.queryManager.queries` `Map` is gone in v4, replaced by `obsQueries` (not equivalent), and `ObservableQuery.queryId` was removed. Rather than branching on the installed version, this switches to APIs that are public and stable across both majors: - Inlines the (trivial) `getOperationName` lookup instead of importing it, so it's no longer tied to either import path. - Replaces `client.queryManager.queries` with the public `client.getObservableQueries()` (a `Map` in v3, a `Set` in v4 — normalized into an array). - Reads `document`/`variables`/`queryName` directly off each `ObservableQuery` (public in both versions) instead of the private `QueryInfo` map entry, and uses `getCurrentResult().data` for cached data instead of the private `diff`/`lastDiff`. - Falls back to a generated id when `ObservableQuery.queryId` isn't present (v4). - `ApolloClientType` is now a small duck-typed interface instead of `ApolloClient<NormalizedCacheObject>`, since the `ApolloClient` class generic was removed entirely in v4 and the old type couldn't compile against both majors at once. - Declares `@apollo/client` as a `peerDependencies` range (`^3.8.0 || ^4.0.0`) — it was previously undeclared. `client.queryManager.mutationStore` is unchanged in shape between v3 and v4, so the mutations path didn't need changes. ## Test plan - [x] `tsc --noEmit` passes with `@apollo/[email protected]` installed - [x] `tsc --noEmit` passes with `@apollo/[email protected]` installed - [x] Added `src/__tests__/utils.test.ts` covering the new `getOperationName` lookup and the `Map`/`Set` normalization; passes under the package's existing jest preset - [ ] Manual check in the example app against both `@apollo/client` v3 and v4 (queries + a mutation) — happy to do this if useful before merge --------- Co-authored-by: Vojtech Novak <[email protected]> Co-authored-by: Claude Fable 5.1 <[email protected]>
53 lines
1.3 KiB
JSON
53 lines
1.3 KiB
JSON
{
|
|
"name": "@dev-plugins/apollo-client",
|
|
"version": "0.4.0",
|
|
"description": "Expo DevTools Plugin for Apollo Client",
|
|
"main": "build/index.js",
|
|
"types": "build/index.d.ts",
|
|
"sideEffects": false,
|
|
"scripts": {
|
|
"build": "expo-module build",
|
|
"clean": "expo-module clean",
|
|
"lint": "expo-module lint",
|
|
"test": "expo-module test",
|
|
"prepare": "expo-module prepare && node ../../scripts/build-webui.js apollo-client",
|
|
"prepublishOnly": "expo-module prepublishOnly",
|
|
"expo-module": "expo-module"
|
|
},
|
|
"homepage": "https://docs.expo.dev/versions/latest/sdk/image/",
|
|
"repository": {
|
|
"type": "git",
|
|
"url": "git+https://github.com/expo/dev-plugins.git",
|
|
"directory": "packages/apollo-client"
|
|
},
|
|
"keywords": [
|
|
"expo",
|
|
"devtools",
|
|
"apollo",
|
|
"apollo-client"
|
|
],
|
|
"files": [
|
|
"build",
|
|
"dist",
|
|
"expo-module.config.json",
|
|
"src"
|
|
],
|
|
"author": "650 Industries, Inc.",
|
|
"license": "MIT",
|
|
"dependencies": {},
|
|
"devDependencies": {
|
|
"@apollo/client": "^3.11.10",
|
|
"@types/react": "~19.0.10",
|
|
"expo": "53.0.7",
|
|
"expo-module-scripts": "^4.1.7",
|
|
"graphql": "^16.9.0",
|
|
"react-dom": "19.1.0",
|
|
"typescript": "~5.8.3"
|
|
},
|
|
"peerDependencies": {
|
|
"@apollo/client": "^3.8.0 || ^4.0.0",
|
|
"expo": ">=53.0.5",
|
|
"react": "*"
|
|
}
|
|
}
|