Skip to content

Instantly share code, notes, and snippets.

@unicodeveloper
Created August 8, 2018 07:26
Show Gist options
  • Save unicodeveloper/4f25a2cc4b92b4bee688ee37218ee531 to your computer and use it in GitHub Desktop.
Save unicodeveloper/4f25a2cc4b92b4bee688ee37218ee531 to your computer and use it in GitHub Desktop.
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