Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add option to query multiple characters by multiple ids in GraphQL #90

Merged
merged 2 commits into from
Aug 22, 2020

Conversation

Ey-Jay
Copy link
Contributor

@Ey-Jay Ey-Jay commented Aug 20, 2020

This aims to provide the same feature currently available in the REST API ex. https://rickandmortyapi.com/api/character/1,2,3

closes #89

@Ey-Jay Ey-Jay changed the title add option to query multiple characters by multiple ids add option to query multiple characters by multiple ids in GraphQL Aug 20, 2020
@afuh
Copy link
Owner

afuh commented Aug 20, 2020

Hey @Ey-Jay that looks great, thank you!!

It would be great if you can implement the same for locationsByIds and episodesByIds.


async charactersByIds({ ids }) {
const data = await this.get('/' + ids)
return data
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you use characterByIds with an array of one id, you will get an error because the API is going to return a single character.

You need to return an array, you should add this:
return Array.isArray(data) ? data : [data]

Copy link
Contributor Author

@Ey-Jay Ey-Jay Aug 20, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right. I missed that one. Changes added 👨🏼‍🎤

@Ey-Jay Ey-Jay requested a review from afuh August 21, 2020 06:55
@afuh
Copy link
Owner

afuh commented Aug 22, 2020

Great stuff! thank you!

@afuh afuh merged commit 52c0029 into afuh:develop Aug 22, 2020
@Ey-Jay
Copy link
Contributor Author

Ey-Jay commented Aug 22, 2020

Thanks a lot!

@Ey-Jay Ey-Jay deleted the characters-by-ids branch August 22, 2020 08:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

query multiple characters by ID in graphql
2 participants