Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions juniper_actix/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@ All user visible changes to `juniper_actix` crate will be documented in this fil

- Switched to 0.4 version of [`actix-ws` crate]. ([#1366])
- Bumped up [MSRV] to 1.88 due to [`actix-ws` crate] requirements. ([#1366])
- `subscriptions::*` functions now require `Clone` bound on the context type for ability to have a "fresh" context value each time a new [GraphQL] operation is started in a [WebSocket] connection. ([#1369])
> **COMPATIBILITY**: Previously, it was `Arc`ed inside, sharing the same context value across all [GraphQL] operations of a [WebSocket] connection. To preserve the previous behavior, the `Schema::Context` type should be either wrapped into `Arc` or made `Arc`-based internally.

[#1366]: /../../pull/1366
[#1369]: /../../pull/1369



Expand Down Expand Up @@ -87,5 +90,7 @@ See [old CHANGELOG](/../../blob/juniper_actix-v0.4.0/juniper_actix/CHANGELOG.md)
[`juniper_graphql_ws` crate]: https://docs.rs/juniper_graphql_ws
[graphql-transport-ws]: https://github.com/enisdenjo/graphql-ws/blob/v5.14.0/PROTOCOL.md
[graphql-ws]: https://github.com/apollographql/subscriptions-transport-ws/blob/v0.11.0/PROTOCOL.md
[GraphQL]: https://graphql.org
[MSRV]: https://doc.rust-lang.org/cargo/reference/manifest.html#the-rust-version-field
[Semantic Versioning 2.0.0]: https://semver.org
[WebSocket]: https://en.wikipedia.org/wiki/WebSocket
6 changes: 3 additions & 3 deletions juniper_actix/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ pub mod subscriptions {
Mutation::TypeInfo: Send + Sync,
Subscription: GraphQLSubscriptionType<S, Context = CtxT> + Send + 'static,
Subscription::TypeInfo: Send + Sync,
CtxT: Unpin + Send + Sync + 'static,
CtxT: Clone + Unpin + Send + Sync + 'static,
S: ScalarValue + Send + Sync + 'static,
I: Init<S, CtxT> + Send,
{
Expand Down Expand Up @@ -250,7 +250,7 @@ pub mod subscriptions {
Mutation::TypeInfo: Send + Sync,
Subscription: GraphQLSubscriptionType<S, Context = CtxT> + Send + 'static,
Subscription::TypeInfo: Send + Sync,
CtxT: Unpin + Send + Sync + 'static,
CtxT: Clone + Unpin + Send + Sync + 'static,
S: ScalarValue + Send + Sync + 'static,
I: Init<S, CtxT> + Send,
{
Expand Down Expand Up @@ -318,7 +318,7 @@ pub mod subscriptions {
Mutation::TypeInfo: Send + Sync,
Subscription: GraphQLSubscriptionType<S, Context = CtxT> + Send + 'static,
Subscription::TypeInfo: Send + Sync,
CtxT: Unpin + Send + Sync + 'static,
CtxT: Clone + Unpin + Send + Sync + 'static,
S: ScalarValue + Send + Sync + 'static,
I: Init<S, CtxT> + Send,
{
Expand Down
15 changes: 14 additions & 1 deletion juniper_axum/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@ All user visible changes to `juniper_axum` crate will be documented in this file



## master

### BC Breaks

- `subscriptions::*` functions now require `Clone` bound on the context type for ability to have a "fresh" context value each time a new [GraphQL] operation is started in a [WebSocket] connection. ([#1369])
> **COMPATIBILITY**: Previously, it was `Arc`ed inside, sharing the same context value across all [GraphQL] operations of a [WebSocket] connection. To preserve the previous behavior, the `Schema::Context` type should be either wrapped into `Arc` or made `Arc`-based internally.

[#1369]: /../../pull/1369




## [0.3.0] · 2025-09-08
[0.3.0]: /../../tree/juniper_axum-v0.3.0/juniper_axum

Expand Down Expand Up @@ -90,4 +102,5 @@ All user visible changes to `juniper_axum` crate will be documented in this file
[GraphQL]: http://graphql.org
[GraphQL Playground]: https://github.com/prisma/graphql-playground
[MSRV]: https://doc.rust-lang.org/cargo/reference/manifest.html#the-rust-version-field
[Semantic Versioning 2.0.0]: https://semver.org
[Semantic Versioning 2.0.0]: https://semver.org
[WebSocket]: https://en.wikipedia.org/wiki/WebSocket
8 changes: 8 additions & 0 deletions juniper_graphql_ws/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,17 @@ All user visible changes to `juniper_graphql_ws` crate will be documented in thi

## master

### BC Breaks

- `Schema::Context` now requires `Clone` bound for ability to have a "fresh" context value each time a new [GraphQL] operation is started in a [WebSocket] connection. ([#1369])
> **COMPATIBILITY**: Previously, it was `Arc`ed inside, sharing the same context value across all [GraphQL] operations of a [WebSocket] connection. To preserve the previous behavior, the `Schema::Context` type should be either wrapped into `Arc` or made `Arc`-based internally.

### Fixed

- Inability to re-subscribe with the same operation `id` after subscription was completed by server. ([#1368])

[#1368]: /../../pull/1368
[#1369]: /../../pull/1369



Expand Down Expand Up @@ -70,5 +76,7 @@ See [old CHANGELOG](/../../blob/juniper_graphql_ws-v0.3.0/juniper_graphql_ws/CHA
[`graphql-ws` npm package]: https://npmjs.com/package/graphql-ws
[`juniper` crate]: https://docs.rs/juniper
[`juniper_subscriptions` crate]: https://docs.rs/juniper_subscriptions
[GraphQL]: https://graphql.org
[MSRV]: https://doc.rust-lang.org/cargo/reference/manifest.html#the-rust-version-field
[Semantic Versioning 2.0.0]: https://semver.org
[WebSocket]: https://en.wikipedia.org/wiki/WebSocket
10 changes: 5 additions & 5 deletions juniper_graphql_ws/src/graphql_transport_ws/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pub use self::{

struct ExecutionParams<S: Schema> {
subscribe_payload: SubscribePayload<S::ScalarValue>,
config: Arc<ConnectionConfig<S::Context>>,
config: ConnectionConfig<S::Context>,
schema: S,
}

Expand Down Expand Up @@ -81,7 +81,7 @@ enum ConnectionState<S: Schema, I: Init<S::ScalarValue, S::Context>> {
PreInit { init: I, schema: S },
/// Active is the state after a ConnectionInit message has been accepted.
Active {
config: Arc<ConnectionConfig<S::Context>>,
config: ConnectionConfig<S::Context>,
stoppers: HashMap<String, oneshot::Sender<()>>,
schema: S,
},
Expand Down Expand Up @@ -121,7 +121,7 @@ impl<S: Schema, I: Init<S::ScalarValue, S::Context>> ConnectionState<S, I> {

(
Self::Active {
config: Arc::new(config),
config,
stoppers: HashMap::new(),
schema,
},
Expand Down Expand Up @@ -484,8 +484,7 @@ where

impl<S, I, T> Sink<T> for Connection<S, I>
where
T: TryInto<Input<S::ScalarValue>>,
T::Error: Error,
T: TryInto<Input<S::ScalarValue>, Error: Error>,
S: Schema,
I: Init<S::ScalarValue, S::Context> + Send,
{
Expand Down Expand Up @@ -605,6 +604,7 @@ mod test {

use super::{Connection, ConnectionConfig, NextPayload, Output, SubscribePayload};

#[derive(Clone, Copy)]
struct Context(i32);

impl juniper::Context for Context {}
Expand Down
10 changes: 5 additions & 5 deletions juniper_graphql_ws/src/graphql_ws/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ pub use self::{

struct ExecutionParams<S: Schema> {
start_payload: StartPayload<S::ScalarValue>,
config: Arc<ConnectionConfig<S::Context>>,
config: ConnectionConfig<S::Context>,
schema: S,
}

Expand All @@ -61,7 +61,7 @@ enum ConnectionState<S: Schema, I: Init<S::ScalarValue, S::Context>> {
PreInit { init: I, schema: S },
/// Active is the state after a ConnectionInit message has been accepted.
Active {
config: Arc<ConnectionConfig<S::Context>>,
config: ConnectionConfig<S::Context>,
stoppers: HashMap<String, oneshot::Sender<()>>,
schema: S,
},
Expand Down Expand Up @@ -112,7 +112,7 @@ impl<S: Schema, I: Init<S::ScalarValue, S::Context>> ConnectionState<S, I> {

(
Self::Active {
config: Arc::new(config),
config,
stoppers: HashMap::new(),
schema,
},
Expand Down Expand Up @@ -430,8 +430,7 @@ where

impl<S, I, T> Sink<T> for Connection<S, I>
where
T: TryInto<ClientMessage<S::ScalarValue>>,
T::Error: Error,
T: TryInto<ClientMessage<S::ScalarValue>, Error: Error>,
S: Schema,
I: Init<S::ScalarValue, S::Context> + Send,
{
Expand Down Expand Up @@ -546,6 +545,7 @@ mod test {

use super::{Connection, ConnectionConfig, ConnectionErrorPayload, DataPayload, StartPayload};

#[derive(Clone, Copy)]
struct Context(i32);

impl juniper::Context for Context {}
Expand Down
15 changes: 11 additions & 4 deletions juniper_graphql_ws/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,15 @@ use juniper::{GraphQLSubscriptionType, GraphQLTypeAsync, RootNode, ScalarValue};
/// Schema defines the requirements for schemas that can be used for operations. Typically this is
/// just an `Arc<RootNode<...>>` and you should not have to implement it yourself.
pub trait Schema: Unpin + Clone + Send + Sync + 'static {
/// The context type.
type Context: Unpin + Send + Sync;
/// The context type associates with this [`Schema`].
///
/// # Cloning
///
/// [`Clone`] is required, because the context type is [`Clone`]d each time a new operation is
/// started over a connection. To share the same context value among all the connection's
/// operations, the context type should be either wrapped into an [`Arc`] or implement
/// [`Arc`]-based [`Clone`]ing by itself.
type Context: Clone + Unpin + Send + Sync;

/// The scalar value type.
type ScalarValue: ScalarValue + Send + Sync;
Expand Down Expand Up @@ -88,7 +95,7 @@ where
MutationT::TypeInfo: Send + Sync,
SubscriptionT: GraphQLSubscriptionType<S, Context = CtxT> + Send + 'static,
SubscriptionT::TypeInfo: Send + Sync,
CtxT: Unpin + Send + Sync + 'static,
CtxT: Clone + Unpin + Send + Sync + 'static,
S: ScalarValue + Send + Sync + 'static,
{
type Context = CtxT;
Expand All @@ -114,7 +121,7 @@ where
MutationT::TypeInfo: Send + Sync,
SubscriptionT: GraphQLSubscriptionType<S, Context = CtxT> + Send + 'static,
SubscriptionT::TypeInfo: Send + Sync,
CtxT: Unpin + Send + Sync,
CtxT: Clone + Unpin + Send + Sync,
S: ScalarValue + Send + Sync + 'static,
{
type Context = CtxT;
Expand Down
14 changes: 14 additions & 0 deletions juniper_warp/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@ All user visible changes to `juniper_warp` crate will be documented in this file



## master

### BC Breaks

- `subscriptions::*` functions now require `Clone` bound on the context type for ability to have a "fresh" context value each time a new [GraphQL] operation is started in a [WebSocket] connection. ([#1369])
> **COMPATIBILITY**: Previously, it was `Arc`ed inside, sharing the same context value across all [GraphQL] operations of a [WebSocket] connection. To preserve the previous behavior, the `Schema::Context` type should be either wrapped into `Arc` or made `Arc`-based internally.

[#1369]: /../../pull/1369




## [0.9.0] · 2025-09-08
[0.9.0]: /../../tree/juniper_warp-v0.9.0/juniper_warp

Expand Down Expand Up @@ -67,5 +79,7 @@ See [old CHANGELOG](/../../blob/juniper_warp-v0.7.0/juniper_warp/CHANGELOG.md).
[`warp` crate]: https://docs.rs/warp
[graphql-transport-ws]: https://github.com/enisdenjo/graphql-ws/blob/v5.14.0/PROTOCOL.md
[graphql-ws]: https://github.com/apollographql/subscriptions-transport-ws/blob/v0.11.0/PROTOCOL.md
[GraphQL]: http://graphql.org
[MSRV]: https://doc.rust-lang.org/cargo/reference/manifest.html#the-rust-version-field
[Semantic Versioning 2.0.0]: https://semver.org
[WebSocket]: https://en.wikipedia.org/wiki/WebSocket
6 changes: 3 additions & 3 deletions juniper_warp/src/subscriptions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ where
Mutation::TypeInfo: Send + Sync,
Subscription: GraphQLSubscriptionType<S, Context = CtxT> + Send + 'static,
Subscription::TypeInfo: Send + Sync,
CtxT: Unpin + Send + Sync + 'static,
CtxT: Clone + Unpin + Send + Sync + 'static,
S: ScalarValue + Send + Sync + 'static,
I: juniper_graphql_ws::Init<S, CtxT> + Clone + Send + Sync,
{
Expand Down Expand Up @@ -235,7 +235,7 @@ where
Mutation::TypeInfo: Send + Sync,
Subscription: GraphQLSubscriptionType<S, Context = CtxT> + Send + 'static,
Subscription::TypeInfo: Send + Sync,
CtxT: Unpin + Send + Sync + 'static,
CtxT: Clone + Unpin + Send + Sync + 'static,
S: ScalarValue + Send + Sync + 'static,
I: juniper_graphql_ws::Init<S, CtxT> + Send,
{
Expand Down Expand Up @@ -282,7 +282,7 @@ where
Mutation::TypeInfo: Send + Sync,
Subscription: GraphQLSubscriptionType<S, Context = CtxT> + Send + 'static,
Subscription::TypeInfo: Send + Sync,
CtxT: Unpin + Send + Sync + 'static,
CtxT: Clone + Unpin + Send + Sync + 'static,
S: ScalarValue + Send + Sync + 'static,
I: juniper_graphql_ws::Init<S, CtxT> + Send,
{
Expand Down