apollo-datasource-spotify
Advanced tools
Comparing version 0.0.10 to 0.0.11
@@ -1,2 +0,2 @@ | ||
import { PagingObject } from '../types/generated'; | ||
import { PagingObject } from './objects'; | ||
interface Params { | ||
@@ -3,0 +3,0 @@ limit?: number; |
@@ -1,4 +0,7 @@ | ||
export { SpotifyAPI, Context } from './spotify-api'; | ||
export { SpotifyAPI, Context } from './api'; | ||
export { batch } from './batch'; | ||
export type { Album, Artist, Playlist, PlaylistTrack, PlayHistory, SavedAlbum, SavedTrack, Track, User, } from '../types/generated'; | ||
export * from './objects'; | ||
export * from './resolvers'; | ||
export * from './responses'; | ||
export * from './typeDefs'; | ||
//# sourceMappingURL=index.d.ts.map |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var spotify_api_1 = require("./spotify-api"); | ||
Object.defineProperty(exports, "SpotifyAPI", { enumerable: true, get: function () { return spotify_api_1.SpotifyAPI; } }); | ||
var api_1 = require("./api"); | ||
Object.defineProperty(exports, "SpotifyAPI", { enumerable: true, get: function () { return api_1.SpotifyAPI; } }); | ||
var batch_1 = require("./batch"); | ||
Object.defineProperty(exports, "batch", { enumerable: true, get: function () { return batch_1.batch; } }); | ||
__exportStar(require("./objects"), exports); | ||
__exportStar(require("./resolvers"), exports); | ||
__exportStar(require("./responses"), exports); | ||
__exportStar(require("./typeDefs"), exports); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "apollo-datasource-spotify", | ||
"version": "0.0.10", | ||
"version": "0.0.11", | ||
"description": "RESTDataSource wrapper for the Spotify API", | ||
@@ -11,4 +11,3 @@ "author": "Jamal Carvalho <jamal.a.carvalho@gmail.com>", | ||
"files": [ | ||
"dist", | ||
"types" | ||
"dist" | ||
], | ||
@@ -22,4 +21,3 @@ "repository": { | ||
"develop": "tsc -w", | ||
"lint": "eslint . --ext .ts", | ||
"graphql": "graphql-codegen" | ||
"lint": "eslint . --ext .ts" | ||
}, | ||
@@ -43,10 +41,8 @@ "husky": { | ||
"devDependencies": { | ||
"@graphql-codegen/cli": "^1.17.7", | ||
"@graphql-codegen/typescript": "^1.17.7", | ||
"@types/jest": "^26.0.14", | ||
"@types/lodash": "^4.14.159", | ||
"@typescript-eslint/eslint-plugin": "^4.0.0", | ||
"@typescript-eslint/parser": "^3.8.0", | ||
"apollo-datasource-rest": "^0.9.3", | ||
"apollo-server-types": "^0.5.1", | ||
"apollo-server": "^2.25.0", | ||
"apollo-server-types": "^0.9.0", | ||
"dataloader": "^2.0.0", | ||
@@ -56,13 +52,11 @@ "eslint": "^7.6.0", | ||
"eslint-plugin-prettier": "^3.1.4", | ||
"graphql": "^15.3.0", | ||
"graphql": "^15.5.0", | ||
"graphql-type-json": "^0.3.2", | ||
"husky": "^4.2.5", | ||
"jest": "^26.4.2", | ||
"lint-staged": "^10.2.11", | ||
"prettier": "^2.0.5", | ||
"ts-jest": "^26.3.0", | ||
"typescript": "^3.9.7" | ||
}, | ||
"dependencies": { | ||
"bottleneck": "^2.19.5", | ||
"lodash": "^4.17.20" | ||
"optionalDependencies": { | ||
"graphql-type-json": "^0.3.2" | ||
}, | ||
@@ -72,4 +66,4 @@ "peerDependencies": { | ||
"dataloader": "^2.0.0", | ||
"graphql": "^15.3.0" | ||
"graphql": "^15.5.0" | ||
} | ||
} |
@@ -0,1 +1,5 @@ | ||
# Apollo Data Source Spotify | ||
## Getting Started | ||
### Install | ||
@@ -23,2 +27,3 @@ | ||
}), | ||
... | ||
}); | ||
@@ -56,1 +61,42 @@ ``` | ||
``` | ||
### Throttling Requests | ||
If you run into issues with rate-limiting, try throttling requests with something | ||
like [bottleneck](https://www.npmjs.com/package/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)); | ||
} | ||
} | ||
``` | ||
## TypeDefs and Resolvers (experimental) | ||
If you use the generated typeDefs and resolvers in a schema you should also implement your own | ||
[custom scalar](https://www.apollographql.com/docs/apollo-server/schema/custom-scalars/) | ||
JSON type or install `graphql-type-json` and [add it to your resolver map](https://www.apollographql.com/docs/apollo-server/schema/custom-scalars/#importing-a-third-party-custom-scalar). | ||
``` | ||
npm install --save graphql-type-json | ||
``` |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
351429
4
16
30
6377
101
1
+ Addedgraphql-type-json@0.3.2(transitive)
- Removedbottleneck@^2.19.5
- Removedlodash@^4.17.20
- Removedbottleneck@2.19.5(transitive)
- Removedlodash@4.17.21(transitive)