Skip to content

Commit

Permalink
Merge 3019e03 into 164051e
Browse files Browse the repository at this point in the history
  • Loading branch information
Ey-Jay committed Aug 20, 2020
2 parents 164051e + 3019e03 commit 30babb8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions graphql/resolvers.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ const resolvers = {
const info = handleInfo({ stats })
return { results, info }
},
charactersByIds: async (_, { ids }, { dataSources }) => {
return dataSources.character.charactersByIds({ ids })
},
character: async (_, { id }, { dataSources }) => {
return dataSources.character.character({ id })
},
Expand Down
5 changes: 5 additions & 0 deletions graphql/sources.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ class Character extends RESTDataSource {
const data = await this.get('/', { ...filter, page })
return data
}

async charactersByIds({ ids }) {
const data = await this.get('/' + ids)
return data
}
async character({ id }) {
const data = await this.get('/' + id)
return data
Expand Down
5 changes: 5 additions & 0 deletions graphql/typeDefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ const typeDefs = gql`
"""
characters(page: Int, filter: FilterCharacter): Characters
"""
Get a list of characters selected by ids
"""
charactersByIds(ids: [ID]): [Character]
"""
Get a specific locations by ID
"""
Expand Down

0 comments on commit 30babb8

Please sign in to comment.