Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
apollo-bus-link
Advanced tools
Your one stop for message bus apollo links
Complex GraphQL based applications may use a separate process to run schema execuation.
This library provides a set of tools which can used to create an ApolloLink and a Schema Executor which can communicate across any JS based message bus.
This library provides pre-written receipes for electron
and webworker
's
Main
import {
createBusLinkBackend,
createSchemaExecutor,
} from "apollo-bus-link/core";
import { electronBus } from "apollo-bus-link/electron";
import { ipcMain } from "electron";
// Args come from the link through `.initialiseBackend`
// You can pass whatever object you want
export type Args = {
mockedMode: boolean;
};
const backend = createBusLinkBackend<Args>({
registerBus: electronBus(mockIpc.ipcMain),
createExecutor: (args) =>
createSchemaExecutor({
// Same API as apollo-server etc
schema,
context,
}),
});
// If you want to preiniitalise the backend, this can be done
// by calling initialise
// backend.initialise(...)
backend.listen();
Renderer
import { createElectronBusLink, electronBus } from "apollo-bus-link/electron";
import { ipcRenderer } from "electron";
import { ApolloClient } from "@apollo/client/core";
const link = createElectronBusLink<Args>(ipcRenderer);
await link.initialiseBackend({ mockedMode: false });
const client = new ApolloClient({
link,
...
});
Worker
import {
createBusLinkBackend,
createSchemaExecutor,
} from "apollo-bus-link/core";
import { webWorkerBus } from "apollo-bus-link/electron";
// Args come from the link through `.initialiseBackend`
// You can pass whatever object you want
export type Args = {
mockedMode: boolean;
};
const backend = createBusLinkBackend<Args>({
registerBus: webWorkerBus(self),
createExecutor: (args) =>
createSchemaExecutor({
schema,
context,
}),
});
// If you want to preiniitalise the backend, this can be done
// by calling initialise
// backend.initialise(...)
backend.listen();
Window
import { createWebWorkerBusLink } from "apollo-bus-link/webworker";
import { ApolloClient } from "@apollo/client/core";
const worker = new Worker(
new URL("./Worker.ts", import.meta.url)
);
const link = createWebWorkerBusLink<Args>(worker);
await link.initialiseBackend({ mockedMode: false });
const client = new ApolloClient({
link,
...
});
Backend
import {
createBusLinkBackend,
createSchemaExecutor,
} from "apollo-bus-link/core";
const backend = createBusLinkBackend<Args>({
registerBus: (request) => {
myMessageBus.onMessage((message) =>
// It may be that you need the context of the initial message
// to be able to response, hence this being callback hell
request(message, (response) => {
myMessageBus.send(response);
})
);
},
createExecutor: (args) =>
createSchemaExecutor({
// Same API as apollo-server etc
schema,
context,
}),
});
Link
import { BusLink } from "apollo-bus-link/core";
import { ApolloClient } from "@apollo/client/core";
const link = new BusLink({
requestHandler: (request) => {
myMessageBus.send(request);
},
registerResponseHandler: (handler) => {
myMessageBus.onMessage((response) => handler(response));
},
});
await link.initialiseBackend({ mockedMode: false });
const client = new ApolloClient({
link,
...
});
MIT
FAQs
Unknown package
We found that apollo-bus-link 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
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.