Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

graphql-spotify

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphql-spotify - npm Package Compare versions

Comparing version 0.4.14 to 0.4.15

src/schema/Category.js

188

dist/lib.js

@@ -85,3 +85,3 @@ module.exports =

var _resolvers = __webpack_require__(14);
var _resolvers = __webpack_require__(16);

@@ -160,2 +160,10 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var _Category = __webpack_require__(14);
var _Category2 = _interopRequireDefault(_Category);
var _RootQuery = __webpack_require__(15);
var _RootQuery2 = _interopRequireDefault(_RootQuery);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -170,36 +178,4 @@

const RootQuery = `
type RootQuery {
featuredPlaylists(limit: Int, offset: Int): Paging
"""
Returns the most recent 50 tracks played by a user
"""
recentlyPlayed: [PlayHistory]
"""
Get a playlist owned by a Spotify user
"""
playlist(userId: String!, playlistId: String!): Playlist
"""
Get an artist
"""
artist(artistId: String!): Artist
"""
Get audio features of a track
"""
audioFeatures(id: String!): AudioFeatures
"""
Get a track
"""
track(id: String!): Track
}
type Mutation {
"""
"""
saveTrack(trackId: String!): Track
}
`;
const typeDefs = [SchemaDefinition, _RootQuery2.default, _Playlist2.default, _Image2.default, _User2.default, _PlaylistTrack2.default, _Track2.default, _Album2.default, _Artist2.default, _Paging2.default, _AudioFeatures2.default, _PlayHistory2.default, _Category2.default, _ExternalUrls2.default];
const typeDefs = [SchemaDefinition, RootQuery, _Playlist2.default, _Image2.default, _User2.default, _PlaylistTrack2.default, _Track2.default, _Album2.default, _Artist2.default, _Paging2.default, _AudioFeatures2.default, _PlayHistory2.default, _ExternalUrls2.default];
exports.default = typeDefs;

@@ -475,3 +451,3 @@

const Paging = `
union Item = Playlist | PlaylistTrack
union Item = Playlist | PlaylistTrack | Category
type Paging {

@@ -574,10 +550,83 @@ href: String

});
const Category = `
type Category {
"""
A link to the Web API endpoint returning full details of the category.
"""
href: String
icons: [Image]
id: String
name: String
}
`;
exports.default = Category;
/***/ }),
/* 15 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
const RootQuery = `
type RootQuery {
featuredPlaylists(limit: Int, offset: Int): Paging
"""
Returns the most recent 50 tracks played by a user
"""
recentlyPlayed: [PlayHistory]
"""
Get a playlist owned by a Spotify user
"""
playlist(userId: String!, playlistId: String!): Playlist
"""
Get an artist
"""
artist(artistId: String!): Artist
"""
Get audio features of a track
"""
audioFeatures(id: String!): AudioFeatures
"""
Get a track
"""
track(id: String!): Track
"""
https://beta.developer.spotify.com/documentation/web-api/reference/browse/get-list-categories/
Get a list of categories used to tag items in Spotify (on, for example, the Spotify player’s “Browse” tab).
"""
categories(limit: Int, offset: Int): Paging
}
type Mutation {
"""
"""
saveTrack(trackId: String!): Track
}
`;
exports.default = RootQuery;
/***/ }),
/* 16 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.makeResolvers = makeResolvers;
var _SpotifyWebApi = __webpack_require__(15);
var _SpotifyWebApi = __webpack_require__(17);
function makeResolvers(token) {
const {
PlaylistLoader, PlaylistTracksLoader, AlbumLoader, UserLoader, ArtistLoader,
AudioFeaturesLoader, SavedContainsLoader, TrackLoader
PlaylistLoader, PlaylistTracksLoader, AlbumsLoader, UserLoader, ArtistsLoader,
AudioFeaturesLoader, SavedContainsLoader, TracksLoader, CategoriesLoader
} = (0, _SpotifyWebApi.makeLoaders)(token);

@@ -599,9 +648,13 @@

artist: async (obj, { artistId }) => {
return await ArtistLoader.load(artistId);
return await ArtistsLoader.load(artistId);
},
track: async (obj, { id }) => {
return await TrackLoader.load(id);
return await TracksLoader.load(id);
},
audioFeatures: async (obj, { id }) => {
return await AudioFeaturesLoader.load(id);
},
categories: async (obj, args) => {
const res = await CategoriesLoader.load(args);
return res.categories;
}

@@ -661,15 +714,15 @@ },

followerCount: async ({ id }) => {
const artistFull = await ArtistLoader.load(id);
const artistFull = await ArtistsLoader.load(id);
return artistFull.followers.total;
},
images: async ({ id }) => {
const artistFull = await ArtistLoader.load(id);
const artistFull = await ArtistsLoader.load(id);
return artistFull.images;
},
popularity: async ({ id }) => {
const artistFull = await ArtistLoader.load(id);
const artistFull = await ArtistsLoader.load(id);
return artistFull.popularity;
},
genres: async ({ id }) => {
const artistFull = await ArtistLoader.load(id);
const artistFull = await ArtistsLoader.load(id);
return artistFull.genres;

@@ -681,19 +734,19 @@ }

genres: async object => {
const AlbumFull = await AlbumLoader.load(object.id);
const AlbumFull = await AlbumsLoader.load(object.id);
return AlbumFull.genres;
},
label: async object => {
const AlbumFull = await AlbumLoader.load(object.id);
const AlbumFull = await AlbumsLoader.load(object.id);
return AlbumFull.label;
},
popularity: async object => {
const AlbumFull = await AlbumLoader.load(object.id);
const AlbumFull = await AlbumsLoader.load(object.id);
return AlbumFull.popularity;
},
release_date: async object => {
const { release_date } = await AlbumLoader.load(object.id);
const { release_date } = await AlbumsLoader.load(object.id);
return release_date;
},
release_date_precision: async object => {
const { release_date_precision } = await AlbumLoader.load(object.id);
const { release_date_precision } = await AlbumsLoader.load(object.id);
return release_date_precision;

@@ -714,2 +767,3 @@ }

}
return 'Category';
}

@@ -722,3 +776,3 @@ }

/***/ }),
/* 15 */
/* 17 */
/***/ (function(module, exports, __webpack_require__) {

@@ -735,2 +789,3 @@

exports.getFeaturedPlaylists = getFeaturedPlaylists;
exports.getCategories = getCategories;
exports.getRecentlyPlayed = getRecentlyPlayed;

@@ -753,6 +808,7 @@ exports.getPlaylist = getPlaylist;

exports.makeAudioFeaturesLoader = makeAudioFeaturesLoader;
exports.makeCategoriesLoader = makeCategoriesLoader;
__webpack_require__(16);
__webpack_require__(18);
var _dataloader = __webpack_require__(17);
var _dataloader = __webpack_require__(19);

@@ -802,2 +858,11 @@ var _dataloader2 = _interopRequireDefault(_dataloader);

async function getCategories(token, queryParams = {}) {
let res = await fetch(`https://api.spotify.com/v1/browse/categories?${serializeToURLParameters(queryParams)}`, {
method: 'GET',
headers: makeHeaders(token)
});
res = await res.json();
return res;
}
async function getRecentlyPlayed(token) {

@@ -880,3 +945,3 @@ const url = "https://api.spotify.com/v1/me/player/recently-played?limit=50";

PlaylistLoader: makePlaylistLoader(token),
PlaylistTracksLoader: makePlaylistLoader(token),
PlaylistTracksLoader: makePlaylistTracksLoader(token),
AlbumsLoader: makeAlbumsLoader(token),

@@ -886,3 +951,4 @@ ArtistsLoader: makeArtistsLoader(token),

SavedContainsLoader: makeSavedContainsLoader(token),
AudioFeaturesLoader: makeAudioFeaturesLoader(token)
AudioFeaturesLoader: makeAudioFeaturesLoader(token),
CategoriesLoader: makeCategoriesLoader(token)
};

@@ -943,4 +1009,3 @@ }

const batchLoadFn = async keys => {
const saved = await getSavedContains(token, keys);
return saved;
return await getSavedContains(token, keys);
};

@@ -958,4 +1023,11 @@ return new _dataloader2.default(batchLoadFn, { maxBatchSize: 50 });

function makeCategoriesLoader(token) {
const batchLoadFn = async ([key]) => {
return [await getCategories(token, key)];
};
return new _dataloader2.default(batchLoadFn, { batch: false });
}
/***/ }),
/* 16 */
/* 18 */
/***/ (function(module, exports) {

@@ -966,3 +1038,3 @@

/***/ }),
/* 17 */
/* 19 */
/***/ (function(module, exports) {

@@ -969,0 +1041,0 @@

{
"name": "graphql-spotify",
"version": "0.4.14",
"version": "0.4.15",
"description": "GraphQL Schema And Resolvers For Spotify Web API",

@@ -5,0 +5,0 @@ "main": "dist/lib.js",

import {
getCategories,
getFeaturedPlaylists, getRecentlyPlayed, makeLoaders, saveTrackToLib

@@ -7,4 +8,4 @@ } from './SpotifyWebApi'

const {
PlaylistLoader, PlaylistTracksLoader, AlbumLoader, UserLoader, ArtistLoader,
AudioFeaturesLoader, SavedContainsLoader, TrackLoader
PlaylistLoader, PlaylistTracksLoader, AlbumsLoader, UserLoader, ArtistsLoader,
AudioFeaturesLoader, SavedContainsLoader, TracksLoader, CategoriesLoader
} = makeLoaders(token);

@@ -26,9 +27,13 @@

artist: async(obj, {artistId}) => {
return await ArtistLoader.load(artistId)
return await ArtistsLoader.load(artistId)
},
track: async(obj, {id}) => {
return await TrackLoader.load(id)
return await TracksLoader.load(id)
},
audioFeatures: async (obj, {id}) => {
return await AudioFeaturesLoader.load(id)
},
categories: async (obj, args) => {
const res = await CategoriesLoader.load(args)
return res.categories
}

@@ -88,15 +93,15 @@ },

followerCount: async ({ id }) => {
const artistFull = await ArtistLoader.load(id)
const artistFull = await ArtistsLoader.load(id)
return artistFull.followers.total
},
images: async ({ id }) => {
const artistFull = await ArtistLoader.load(id)
const artistFull = await ArtistsLoader.load(id)
return artistFull.images
},
popularity: async ({ id }) => {
const artistFull = await ArtistLoader.load(id)
const artistFull = await ArtistsLoader.load(id)
return artistFull.popularity
},
genres: async ({ id }) => {
const artistFull = await ArtistLoader.load(id)
const artistFull = await ArtistsLoader.load(id)
return artistFull.genres

@@ -108,19 +113,19 @@ },

genres: async (object) => {
const AlbumFull = await AlbumLoader.load(object.id)
const AlbumFull = await AlbumsLoader.load(object.id)
return AlbumFull.genres
},
label: async (object) => {
const AlbumFull = await AlbumLoader.load(object.id)
const AlbumFull = await AlbumsLoader.load(object.id)
return AlbumFull.label
},
popularity: async (object) => {
const AlbumFull = await AlbumLoader.load(object.id)
const AlbumFull = await AlbumsLoader.load(object.id)
return AlbumFull.popularity
},
release_date: async (object) => {
const { release_date } = await AlbumLoader.load(object.id)
const { release_date } = await AlbumsLoader.load(object.id)
return release_date
},
release_date_precision: async (object) => {
const { release_date_precision } = await AlbumLoader.load(object.id)
const { release_date_precision } = await AlbumsLoader.load(object.id)
return release_date_precision

@@ -141,2 +146,3 @@ }

}
return 'Category'
}

@@ -143,0 +149,0 @@ }

@@ -12,2 +12,4 @@ import Playlist from './Playlist'

import ExternalUrls from './ExternalUrls'
import Category from './Category'
import RootQuery from './RootQuery'

@@ -21,37 +23,5 @@ const SchemaDefinition = `

const RootQuery = `
type RootQuery {
featuredPlaylists(limit: Int, offset: Int): Paging
"""
Returns the most recent 50 tracks played by a user
"""
recentlyPlayed: [PlayHistory]
"""
Get a playlist owned by a Spotify user
"""
playlist(userId: String!, playlistId: String!): Playlist
"""
Get an artist
"""
artist(artistId: String!): Artist
"""
Get audio features of a track
"""
audioFeatures(id: String!): AudioFeatures
"""
Get a track
"""
track(id: String!): Track
}
type Mutation {
"""
"""
saveTrack(trackId: String!): Track
}
`;
const typeDefs = [SchemaDefinition, RootQuery, Playlist, Image, User, PlaylistTrack, Track, Album, Artist, Paging,
AudioFeatures, PlayHistory, ExternalUrls];
AudioFeatures, PlayHistory, Category, ExternalUrls];
export default typeDefs
const Paging = `
union Item = Playlist | PlaylistTrack
union Item = Playlist | PlaylistTrack | Category
type Paging {

@@ -4,0 +4,0 @@ href: String

@@ -45,2 +45,12 @@ import 'isomorphic-fetch'

export async function getCategories(token, queryParams = {})
{
let res = await fetch(`https://api.spotify.com/v1/browse/categories?${serializeToURLParameters(queryParams)}`, {
method: 'GET',
headers: makeHeaders(token)
});
res = await res.json();
return res;
}
export async function getRecentlyPlayed(token) {

@@ -130,3 +140,3 @@ const url = "https://api.spotify.com/v1/me/player/recently-played?limit=50"

PlaylistLoader : makePlaylistLoader(token),
PlaylistTracksLoader: makePlaylistLoader(token),
PlaylistTracksLoader: makePlaylistTracksLoader(token),
AlbumsLoader: makeAlbumsLoader(token),

@@ -136,3 +146,4 @@ ArtistsLoader: makeArtistsLoader(token),

SavedContainsLoader: makeSavedContainsLoader(token),
AudioFeaturesLoader: makeAudioFeaturesLoader(token)
AudioFeaturesLoader: makeAudioFeaturesLoader(token),
CategoriesLoader : makeCategoriesLoader(token),
}

@@ -193,4 +204,3 @@ }

const batchLoadFn = async (keys) => {
const saved = await getSavedContains(token, keys)
return saved
return await getSavedContains(token, keys)
}

@@ -206,2 +216,9 @@ return new Dataloader(batchLoadFn, { maxBatchSize: 50 })

return new Dataloader(batchLoadFn, { maxBatchSize: 50 })
}
export function makeCategoriesLoader(token) {
const batchLoadFn = async ([key]) => {
return [await getCategories(token, key)]
}
return new Dataloader(batchLoadFn, { batch: false })
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc