Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
@enisdenjo/graphql-transport-ws
Advanced tools
🔗 A coherent, zero-dependency, lazy, simple and easy to use server and client implementation of the GraphQL over WebSocket Protocol.
yarn add @enisdenjo/graphql-transport-ws
# or
npm install @enisdenjo/graphql-transport-ws
import { createClient } from '@enisdenjo/graphql-transport-ws';
import { Network, Observable } from 'relay-runtime';
const subscriptionsClient = createClient({
url: 'wss://some.url/graphql',
connectionParams: () => {
const session = getSession();
if (!session) {
return null;
}
return {
Authorization: `Bearer ${session.token}`,
};
},
});
export const network = Network.create(
// fetch
(operation, variables, cacheConfig) => {
return Observable.create((sink) => {
fetchQuery(operation, variables, cacheConfig, sink);
});
},
// subscribe
(operation, variables) => {
return Observable.create((sink) => {
if (!operation.text) {
return sink.error(new Error('Operation text cannot be empty'));
}
return subscriptionsClient.subscribe(
{
operationName: operation.name,
query: operation.text,
variables,
},
sink,
);
});
},
);
import { print } from 'graphql';
import { ApolloLink, Operation, FetchResult, Observable } from '@apollo/client';
import { createClient, Config, Client } from '@enisdenjo/graphql-transport-ws';
class WebSocketLink extends ApolloLink {
private client: Client;
constructor(config: Config) {
super();
this.client = createClient(config);
}
public request({
operationName,
query,
variables,
}: Operation): Observable<FetchResult> {
return new Observable((sink) => {
return this.client.subscribe<FetchResult>(
{ operationName, query: print(query), variables },
sink,
);
});
}
}
const link = new WebSocketLink({
url: 'wss://some.url/graphql',
connectionParams: () => {
const session = getSession();
if (!session) {
return null;
}
return {
Authorization: `Bearer ${session.token}`,
};
},
});
TypeDoc generated documentation is located in the docs folder.
Read about the exact transport protocol used by the library in the PROTOCOL.md document.
File a bug, contribute with code, or improve documentation? Welcome 👋! Read up on our guidelines for contributing.
1.1.1 (2020-08-28)
Package has been renamed from graphql-transport-ws
to graphql-ws
.
FAQs
A WebSocket client for GraphQL subscriptions
The npm package @enisdenjo/graphql-transport-ws receives a total of 7 weekly downloads. As such, @enisdenjo/graphql-transport-ws popularity was classified as not popular.
We found that @enisdenjo/graphql-transport-ws demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.