![Maven Central Adds Sigstore Signature Validation](https://cdn.sanity.io/images/cgdhsj6q/production/7da3bc8a946cfb5df15d7fcf49767faedc72b483-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Maven Central Adds Sigstore Signature Validation
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
@vital-software/redux-graphql-subscriptions
Advanced tools
A Redux middleware for managing GraphQL Subscriptions.
A Redux middleware for handling GraphQL subscriptions.
This repo leverages subscriptions-transport-ws which is the awesome work of the Apollo guys over here and is intended to be coupled with a backend server that also uses subscriptions-transport-ws or conforms to the same protocol.
This is totally work in progress so all comment, critique and help welcomed!
yarn add redux-graphql-subscriptions
import { createStore, combineReducers, applyMiddleware } from 'redux'
import reducers from 'reducers'
import { createMiddleware } from 'redux-graphql-subscriptions'
const graphQLSubscriptionsMiddleware = createMiddleware('ws://localhost:8001/subscriptions', { reconnect: true })
let todoApp = combineReducers(reducers)
let store = createStore(
todoApp,
applyMiddleware(logger, graphQLSubscriptionsMiddleware)
)
import { subscribe, unsubscribe } from 'redux-graphql-subscriptions'
export const subscribeToNewComments = () => subscribe({ ...newComment, { channel: 'one' } })
export const unsubscribeFromNewComments = () => unsubscribe('one')
// Subscription object
const newComment = {
query: newCommentSubscription,
onMessage: receivedNewComment,
onError: receivedNewCommentWithErrors,
onUnsubscribe: threadClosed
}
Clone the repo and boot up the working example to see how to integrate it into your app:
git clone git@github.com:hally9k/redux-graphql-subscriptions.git
Run the server:
cd example/server
yarn
yarn start
cd ../..
(Back to the root for the next step)Run the client:
yarn
yarn link
cd example/client
yarn
yarn link "redux-graphql-subscriptions"
yarn start
Once you have the app running make a subscription and test the automatic reconnections by killing and standing up the server.
createMiddleware(url, options)
url: string
: url that the client will connect to, starts with ws://
or wss://
options?: Object
: optional, object to modify default client behavior
timeout?: number
: how long the client should wait in ms for a keep-alive message from the server (default 10000 ms), this parameter is ignored if the server does not send keep-alive messages. This will also be used to calculate the max connection time per connect/reconnectlazy?: boolean
: use to set lazy mode - connects only when first subscription created, and delay the socket initializationconnectionParams?: Object | Function
: object that will be available as first argument of onConnect
(in server side), if passed a function - it will call it and send the return valuereconnect?: boolean
: automatic reconnect in case of connection errorreconnectionAttempts?: number
: how many reconnect attemptsconnectionCallback?: (error) => {}
: optional, callback that called after the first init message, with the error (if there is one)subscribe(subscription)
subscription: Object
: the required fields for a subscription
query: string
: GraphQL subscriptionvariables?: Object
: GraphQL subscription variables, requires channel
value to be set to denote the channel to listen to.onMessage: function
: The action creator to be dispatched when a message is received without any errorsonError: function
: The action creator to be dispatched when a message is received that does contain errorsonUnsubscribe: function
: The action creator to be dispatched when the client unsubscribes form a subscriptionunsubscribe(channel)
channel: string
: channel to unsubscribe fromFAQs
A Redux middleware for managing GraphQL Subscriptions.
The npm package @vital-software/redux-graphql-subscriptions receives a total of 0 weekly downloads. As such, @vital-software/redux-graphql-subscriptions popularity was classified as not popular.
We found that @vital-software/redux-graphql-subscriptions demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 12 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.