![Namecheap Takes Down Polyfill.io Service Following Supply Chain Attack](https://cdn.sanity.io/images/cgdhsj6q/production/6af25114feaaac7179b18127c83327568ff592d1-1024x1024.webp?w=800&fit=max&auto=format)
Security News
Namecheap Takes Down Polyfill.io Service Following Supply Chain Attack
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
apollo-datasource-spotify
Advanced tools
Readme
npm install apollo-datasource-rest dataloader graphql
import { SpotifyAPI } from 'apollo-datasource-spotify';
const apollo = new ApolloServer({
context: ({ req }) => {
return {
authorization: req.headers.authorization,
// OR
token: req.user.token,
};
},
dataSources: () => ({
spotify: new SpotifyAPI(),
}),
...
});
export const resolvers = {
Query: {
me(root, args, context) {
return context.dataSources.spotify.me();
},
},
};
import { batch } from 'apollo-datasource-spotify';
const resolver = async (root, args, context) {
await batch({
limit: 2500,
request: (params) => dataSources.spotify.savedTracks(params),
callback: async (savedTracks) => {
console.log(savedTracks);
},
});
return;
};
If you run into issues with rate-limiting, try throttling requests with something like bottleneck.
npm install --save bottleneck
import SpotifyAPI from 'apollo-datasource-rest';
import Bottleneck from 'bottleneck';
class ThrottledSpotifyAPI extends SpotifyAPI {
constructor() {
super();
this.limiter = new Bottleneck({
reservoir: 100,
reservoirRefreshAmount: 100,
reservoirRefreshInterval: 60 * 1000,
maxConcurrent: 1,
minTime: 333,
});
this.get = this.limiter.wrap(this.get.bind(this));
this.post = this.limiter.wrap(this.post.bind(this));
this.put = this.limiter.wrap(this.put.bind(this));
this.delete = this.limiter.wrap(this.delete.bind(this));
}
}
If you use the generated typeDefs and resolvers in a schema you should also implement your own
custom scalar
JSON type or install graphql-type-json
and add it to your resolver map.
npm install --save graphql-type-json
FAQs
RESTDataSource wrapper for the Spotify API
The npm package apollo-datasource-spotify receives a total of 0 weekly downloads. As such, apollo-datasource-spotify popularity was classified as not popular.
We found that apollo-datasource-spotify 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.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.
Security News
A JavaScript library maintainer is under fire after merging a controversial PR to support legacy versions of Node.js.