AurelicButter / AniList-Node

A lightweight Node.js wrapper for the AniList API
https://katsurin.com/docs/anilist-node/
MIT License
44 stars 19 forks source link

TS typings - Media fixes #25

Closed rd-xx closed 3 years ago

rd-xx commented 3 years ago

Hi, I just started using the lib and noticed a small typo in the Media interface. Proof: Py7drdb

rd-xx commented 3 years ago

Also, why can the (media) trailer property be a string? From the official GraphQL docs it can only be an object (or null) Nz2TlTQ

I just want to know if this is an error or there's an explanation. If this is an error l'd gladly fix it

AurelicButter commented 3 years ago

Also, why can the (media) trailer property be a string? From the official GraphQL docs it can only be an object (or null) Nz2TlTQ

I just want to know if this is an error or there's an explanation. If this is an error l'd gladly fix it

AniList-Node transforms the data a bit to make getting information easier so the return object is not always a 1:1 comparison.

For media.trailer, if it is YouTube or Dailymotion, it will generate the link and use that instead of the object. So it's working as intended. 😃 You can see this in the fetcher function here: https://github.com/Butterstroke/AniList-Node/blob/4f35d3aaa5dad8897b56d0914029f2eb6a3084e1/lib/fetcher.js#L89-L102

rd-xx commented 3 years ago

AniList-Node transforms the data a bit to make getting information easier so the return object is not always a 1:1 comparison.

For media.trailer, if it is YouTube or Dailymotion, it will generate the link and use that instead of the object. So it's working as intended. 😃 You can see this in the fetcher function here:

Oh okay, didn't know about that. Really cool feature 😃

rd-xx commented 3 years ago

As said in the commit description: The typings say that PersonRelation's property "name" return an object with 1 property named "english", when in reality it returns a string, we can see it here: https://github.com/Butterstroke/AniList-Node/blob/4f35d3aaa5dad8897b56d0914029f2eb6a3084e1/lib/fetcher.js#L31-L33

AurelicButter commented 3 years ago

As said in the commit description: The typings say that PersonRelation's property "name" return an object with 1 property named "english", when in reality it returns a string, we can see it here: https://github.com/Butterstroke/AniList-Node/blob/4f35d3aaa5dad8897b56d0914029f2eb6a3084e1/lib/fetcher.js#L31-L33

Ah, good catch! Consider this comment approval for that since the PR is already approved for the other changes.

AurelicButter commented 3 years ago

Merged this for a bug fix update soon. Thanks for the work!