Skip to content

fix: unwrapFieldTypeName#57

Merged
mcollina merged 2 commits into
platformatic:mainfrom
DorianGrey11:fix/unwrapFieldTypeName
Jul 17, 2024
Merged

fix: unwrapFieldTypeName#57
mcollina merged 2 commits into
platformatic:mainfrom
DorianGrey11:fix/unwrapFieldTypeName

Conversation

@DorianGrey11
Copy link
Copy Markdown
Contributor

In some cases, the unwrapFieldTypeName function returned null because an object was too nested.
This resulted in a TypeError [Error]: Cannot read properties of undefined.

I have adapted the tests to demonstrate this by simply having a [Book!]! return type.
In the example, the field object looks like this:

{
  "kind": "NON_NULL",
  "name": null,
  "ofType": {
    "kind": "LIST",
    "name": null,
    "ofType": {
      "kind": "NON_NULL",
      "name": null,
      "ofType": {
        "kind": "OBJECT",
        "name": "Book",
        "ofType": null
      }
    }
  }
}

The previous approach would return field.type.ofType.ofType.name, which is still null instead of the desired Book type. In order to fix this, I made the unwrapFieldTypeName function work recursively.

Copy link
Copy Markdown
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

@mcollina mcollina merged commit dad582b into platformatic:main Jul 17, 2024
@mcollina
Copy link
Copy Markdown
Member

thanks!!

@DorianGrey11 DorianGrey11 deleted the fix/unwrapFieldTypeName branch July 17, 2024 14:02
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.

2 participants