From be2029b7c929aadb53073a05b4615638016d82f8 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 2 Nov 2023 10:00:15 -0400 Subject: [PATCH] Version Packages (alpha) (#11336) Co-authored-by: github-actions[bot] --- .changeset/pre.json | 3 ++ CHANGELOG.md | 84 +++++++++++++++++++++++++++++++++++++++++++++ package-lock.json | 4 +-- package.json | 2 +- 4 files changed, 90 insertions(+), 3 deletions(-) diff --git a/.changeset/pre.json b/.changeset/pre.json index 97962fa8e7a..ba0a83ecf37 100644 --- a/.changeset/pre.json +++ b/.changeset/pre.json @@ -6,8 +6,11 @@ }, "changesets": [ "beige-geese-wink", + "breezy-spiders-tap", + "good-experts-repair", "shaggy-ears-scream", "sour-sheep-walk", + "strong-terms-perform", "yellow-flies-repeat" ] } diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a3c2bcc7ab..f15a55ef9cb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,89 @@ # @apollo/client +## 3.9.0-alpha.3 + +### Minor Changes + +- [#11301](https://github.com/apollographql/apollo-client/pull/11301) [`46ab032af`](https://github.com/apollographql/apollo-client/commit/46ab032af83a01f184bfcce5edba4b55dbb2962a) Thanks [@alessbell](https://github.com/alessbell)! - Add multipart subscription network adapters for Relay and urql + + ### Relay + + ```tsx + import { createFetchMultipartSubscription } from "@apollo/client/utilities/subscriptions/relay"; + import { Environment, Network, RecordSource, Store } from "relay-runtime"; + + const fetchMultipartSubs = createFetchMultipartSubscription( + "http://localhost:4000" + ); + + const network = Network.create(fetchQuery, fetchMultipartSubs); + + export const RelayEnvironment = new Environment({ + network, + store: new Store(new RecordSource()), + }); + ``` + + ### Urql + + ```tsx + import { createFetchMultipartSubscription } from "@apollo/client/utilities/subscriptions/urql"; + import { Client, fetchExchange, subscriptionExchange } from "@urql/core"; + + const url = "http://localhost:4000"; + + const multipartSubscriptionForwarder = createFetchMultipartSubscription(url); + + const client = new Client({ + url, + exchanges: [ + fetchExchange, + subscriptionExchange({ + forwardSubscription: multipartSubscriptionForwarder, + }), + ], + }); + ``` + +### Patch Changes + +- [#11275](https://github.com/apollographql/apollo-client/pull/11275) [`3862f9ba9`](https://github.com/apollographql/apollo-client/commit/3862f9ba9086394c4cf4c2ecd99e8e0f6cf44885) Thanks [@phryneas](https://github.com/phryneas)! - Add a `defaultContext` option and property on `ApolloClient`, e.g. for keeping track of changing auth tokens or dependency injection. + + This can be used e.g. in authentication scenarios, where a new token might be + generated outside of the link chain and should passed into the link chain. + + ```js + import { ApolloClient, createHttpLink, InMemoryCache } from "@apollo/client"; + import { setContext } from "@apollo/client/link/context"; + + const httpLink = createHttpLink({ + uri: "/graphql", + }); + + const authLink = setContext((_, { headers, token }) => { + return { + headers: { + ...headers, + authorization: token ? `Bearer ${token}` : "", + }, + }; + }); + + const client = new ApolloClient({ + link: authLink.concat(httpLink), + cache: new InMemoryCache(), + }); + + // somewhere else in your application + function onNewToken(newToken) { + // token can now be changed for future requests without need for a global + // variable, scoped ref or recreating the client + client.defaultContext.token = newToken; + } + ``` + +- [#11297](https://github.com/apollographql/apollo-client/pull/11297) [`c8c76a522`](https://github.com/apollographql/apollo-client/commit/c8c76a522e593de0d06cff73fde2d9e88152bed6) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Add an explicit return type for the `useReadQuery` hook called `UseReadQueryResult`. Previously the return type of this hook was inferred from the return value. + ## 3.9.0-alpha.2 ### Patch Changes diff --git a/package-lock.json b/package-lock.json index c03bfde63f7..e80382241a3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@apollo/client", - "version": "3.9.0-alpha.2", + "version": "3.9.0-alpha.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@apollo/client", - "version": "3.9.0-alpha.2", + "version": "3.9.0-alpha.3", "hasInstallScript": true, "license": "MIT", "dependencies": { diff --git a/package.json b/package.json index ed22fbaab9d..d355f3076f9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@apollo/client", - "version": "3.9.0-alpha.2", + "version": "3.9.0-alpha.3", "description": "A fully-featured caching GraphQL client.", "private": true, "keywords": [