
Research
/Security News
Weaponizing Discord for Command and Control Across npm, PyPI, and RubyGems.org
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
apollo-link
Advanced tools
apollo-link
is a standard interface for modifying control flow of GraphQL requests and fetching GraphQL results, designed to provide a simple GraphQL client that is capable of extensions.
The targeted use cases of apollo-link
are highlighted below:
Apollo Link is the interface for creating new links in your application.
The client sends a request as a method call to a link and can recieve one or more (in the case of subscriptions) responses from the server. The responses are returned using the Observer pattern.
Results from the server can be provided by calling next(result)
on the observer. In the case of a network/transport error (not a GraphQL Error) the error(err)
method can be used to indicate a response will not be recieved. If multiple responses are not supported by the link, complete()
should be called to inform the client no further data will be provided.
In the case of an intermediate link, a second argument to request(operation, forward)
is the link to forward(operation)
to. forward
returns an observable and it can be returned directly or subscribed to.
forward(operation).subscribe({
next: result => {
handleTheResult(result)
},
error: error => {
handleTheNetworkError(error)
},
});
import { ApolloLink, Observable } from 'apollo-link';
export class CustomApolloLink extends ApolloLink {
request(operation /*, forward*/) {
//Whether no one is listening anymore
let unsubscribed = false;
return new Observable(observer => {
somehowGetOperationToServer(operation, (error, result) => {
if (unsubscribed) return;
if (error) {
//Network error
observer.error(error);
} else {
observer.next(result);
observer.complete(); //If subscriptions not supported
}
});
function unsubscribe() {
unsubscribed = true;
}
return unsubscribe;
});
}
}
npm install apollo-link --save
Relay Runtime is a framework from Facebook for building data-driven React applications with GraphQL. It is similar to apollo-link in that it manages GraphQL data operations, but it is tightly integrated with React and uses a different set of abstractions and optimizations specific to React applications.
Urql is a highly customizable and versatile GraphQL client, similar to apollo-link. It features a similar extensible approach with 'exchanges' which are analogous to Apollo's links. However, urql provides a more integrated caching mechanism and a simpler API, which might be preferred for smaller projects or those seeking simplicity.
FAQs
Flexible, lightweight transport layer for GraphQL
The npm package apollo-link receives a total of 1,090,322 weekly downloads. As such, apollo-link popularity was classified as popular.
We found that apollo-link demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 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.
Research
/Security News
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
Security News
Socket now integrates with Bun 1.3’s Security Scanner API to block risky packages at install time and enforce your organization’s policies in local dev and CI.
Research
The Socket Threat Research Team is tracking weekly intrusions into the npm registry that follow a repeatable adversarial playbook used by North Korean state-sponsored actors.