Created
August 8, 2018 07:26
-
-
Save unicodeveloper/4f25a2cc4b92b4bee688ee37218ee531 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { RESTDataSource } = require('apollo-datasource-rest'); | |
class MoviesAPI extends RESTDataSource { | |
constructor() { | |
super(); | |
this.baseURL = 'https://movies-api.example.com/'; | |
} | |
async getMovie(id) { | |
return this.get(`movies/${id}`); | |
} | |
async getMostViewedMovies(limit = 10) { | |
const data = await this.get('movies', { | |
per_page: limit, | |
order_by: 'most_viewed', | |
}); | |
return data.results; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment