Didas-git / anilist-wrapper

An UNOFFICIAL wrapper for the anilist graphql api
9 stars 1 forks source link

GraphQL error with character name #8

Closed obaidabit closed 1 year ago

obaidabit commented 1 year ago

Bug Report

Current Behavior

When calling the withName() function,inside a character query of media query I'm getting the following error: this is the response result from Anilist

{
    "errors": [
        {
            "message": "Field \"name\" of type \"CharacterName\" must have a sub selection.",
            "status": 400,
            "locations": [
                {
                    "line": 30,
                    "column": 21
                }
            ]
        }
    ],
    "data": null
}

Steps to Reproduce

  1. Use media() query
  2. Use withCharacters()
  3. Add edges to the withCharacters
  4. Add withNode() to the edges
  5. Add withName() to the node
anilist.query
    .media({ id: id })
    .withCharacters({
      edges: (edges) => {
        edges.withNode((node) => node.withId().withName());
        return edges.withRole();
      },
    }).fetch();

the GraphQL query looks like this

query {
  Media(id: 20) {
    characters {
      edges {
        node {
          id
          name
        }
        role
      }
    }
  }
}

Expected Behavior

I expect the query to look like this

query {
  Media(id: 20) {
    characters {
      edges {
        node {
          id
          name {
            userPreferred
          }
        }
        role
      }
    }
  }
}

Environment

Possible Solution

...

Additional Context

this bug also exists with character image.

Didas-git commented 1 year ago

I have looked into this and i forgot to complete the withName and withImage implementations, this also affects StaffQuery and StudioQuery, i will be releasing a patch as soon as im able to hop on my pc. Thanks for the report!

Didas-git commented 1 year ago

Patch 0.12.2 was posted and this issue was fixed (4cd5b3c406ed92cce9cce91e27a9109d5c0d12ac). Also i made a wrong assessment and StudioQuery was not impacted by this.

obaidabit commented 1 year ago

thanks, It is working now.