
Product
Rust Support Now in Beta
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.
@gospime/apollo-client
Advanced tools
Apollo HTTP client with response caching
Options:
const uri = `https://${hostname}:${port}${graphqlPath}`;
// options of https.Agent
const options = {
//rejectUnauthorized: false // Skip SSL-restrictions
};
ApolloOptions: fetch-policy
const apolloOptions = {
query: {
// How you want your component to interact with the Apollo cache.
// Defaults to "cache-first".
fetchPolicy: 'no-cache',
// How you want your component to handle network and GraphQL errors.
// Defaults to "none", which means we treat GraphQL errors as runtime errors.
errorPolicy: 'all',
}
};
Example: how to execute graphql query
const Client = require('@gospime/apollo-client');
const plan = 'userSelect';
const args = { id: 2 }; // criteria to find a user
const fields = { fullname, email }; // fields to select
// calling of `query` method
Client
.create(uri, options, apolloOptions)
.query({ plan, args, fields })
.then(result => console.log(result))
.catch(error => console.error(error));
Example: how to execute graphql mutation
const Client = require('@gospime/apollo-client');
const plan = 'userEdit';
const args = { id: 2, fullname: 'new fullname' }; // find user by `id` and update the fullname
// calling of `mutate` method
Client
.create(uri, options, apolloOptions)
.mutate({ plan, args })
.then(result => console.log(result))
.catch(error => console.error(error));
Async/await example:
async () => await Client.create(uri, options, apolloOptions).mutate({ plan, args });
FAQs
Apollo HTTP client with response caching
We found that @gospime/apollo-client 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.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.