Skip to content
This repository was archived by the owner on Dec 23, 2017. It is now read-only.

Commit 2f864f4

Browse files
committed
fix: remove duplicated code and clean up a bit
1 parent b9bafe4 commit 2f864f4

File tree

2 files changed

+3
-14
lines changed

2 files changed

+3
-14
lines changed

src/model.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ export default class IMDBAPIModel extends GraphQLModel {
2929
.catch(res =>
3030
this.throwError(res, {
3131
description: 'Unable to search movies',
32-
docsLink: 'https://github.com/gramps-express/data-source-imdbapi',
3332
}),
3433
);
3534
}
@@ -50,7 +49,6 @@ export default class IMDBAPIModel extends GraphQLModel {
5049
.catch(res =>
5150
this.throwError(res, {
5251
description: 'Unable to search people',
53-
docsLink: 'https://github.com/gramps-express/data-source-imdbapi',
5452
}),
5553
);
5654
}
@@ -68,7 +66,6 @@ export default class IMDBAPIModel extends GraphQLModel {
6866
.catch(res =>
6967
this.throwError(res, {
7068
description: 'Unable to get movie by ID',
71-
docsLink: 'https://github.com/gramps-express/data-source-imdbapi',
7269
}),
7370
);
7471
}
@@ -86,7 +83,6 @@ export default class IMDBAPIModel extends GraphQLModel {
8683
.catch(res =>
8784
this.throwError(res, {
8885
description: 'Unable to get person by ID',
89-
docsLink: 'https://github.com/gramps-express/data-source-imdbapi',
9086
}),
9187
);
9288
}
@@ -104,7 +100,7 @@ export default class IMDBAPIModel extends GraphQLModel {
104100
description: error.message || 'Something went wrong.',
105101
targetEndpoint: error.options ? error.options.uri : null,
106102
graphqlModel: this.constructor.name,
107-
docsLink: null,
103+
docsLink: 'https://github.com/gramps-express/data-source-imdbapi',
108104
};
109105

110106
throw GrampsError({

src/resolvers.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
import { MockList } from 'graphql-tools';
22
import casual from 'casual';
33

4-
/*
5-
* For more information on data source resolvers, see
6-
* https://ibm.biz/graphql-data-source-resolvers
7-
*/
8-
94
export default {
10-
// Queries (where does the data come from?)
115
queryResolvers: {
126
searchMoviesByTitle: (rootValue, { options }, context) =>
137
new Promise((resolve, reject) => {
@@ -39,9 +33,9 @@ export default {
3933
}),
4034
},
4135

42-
// Data fields (which data from the response goes to which field?)
4336
dataResolvers: {
4437
IMDB_Person: {
38+
// Convert the filmography object into an array for filtering/typing.
4539
filmography: ({ filmography }, { filter = 'all' }) =>
4640
Object.keys(filmography)
4741
.reduce(
@@ -61,12 +55,11 @@ export default {
6155
.filter(work => filter === 'all' || work.position === filter),
6256
},
6357
IMDB_Metadata: {
64-
// Alias this field to fix the typo.
58+
// Alias this field to fix a typo.
6559
asp_ratio: data => data.asp_retio,
6660
},
6761
},
6862

69-
// Mock data (How can I get real-feeling fake data while working offline?)
7063
mockResolvers: {
7164
IMDB_Movie: () => ({
7265
cast: () => new MockList([1, 10]),

0 commit comments

Comments
 (0)