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

Entity resolvers should support partial responses and errors combined #1437

Merged
merged 2 commits into from
Sep 6, 2022

Conversation

SvenW
Copy link
Contributor

@SvenW SvenW commented Aug 11, 2022

Right now I can't find a way for entity resolvers to return both partial responses and the errors to the entities that wasn't resolved.

So either I get

{
  "data": null,
  "errors": [
    {
      "message": "Not found James",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "_entities",
        1
      ]
    }
  ]
}

or I can get

{
  "data": {
    "_entities": [
      {
        "__typename": "Character",
        "name": "James Holden"
      },
      null
    ]
  }
}

by just capturing all errors.
I opened this PR just to get some guidance and to see if you have any input, thanks.

@paulpdaniels
Copy link
Collaborator

I'll look into this, AFAICR it shouldn't be doing anything special wrt to partial resolution, I'm wondering if we even support partial array failures in general 🤔

@SvenW
Copy link
Contributor Author

SvenW commented Sep 6, 2022

So I took a little bit of time yesterday just to see what happens here. It seems that for EntityResolvers we end up here https://github.com/ghostdogpr/caliban/blob/series/2.x/core/src/main/scala/caliban/execution/Executor.scala#L146. Shouldn't these types of steps be liststeps? I can of course solve the issue with some sort of hack here and use handleError. Do you have any pointers?

@SvenW
Copy link
Contributor Author

SvenW commented Sep 6, 2022

So I took a little bit of time yesterday just to see what happens here. It seems that for EntityResolvers we end up here https://github.com/ghostdogpr/caliban/blob/series/2.x/core/src/main/scala/caliban/execution/Executor.scala#L146. Shouldn't these types of steps be liststeps? I can of course solve the issue with some sort of hack here and use handleError. Do you have any pointers?

I looked at the spec for _Entity and noticed it was NON_NULL which caused the Executor to handle it in a faulty way where the items in a ListStep couldn't be nullable thus returning only the errors instead of a partially resolved response.

Copy link
Collaborator

@frekw frekw left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@ghostdogpr
Copy link
Owner

LGTM! @paulpdaniels wanna double check?

@paulpdaniels
Copy link
Collaborator

Easy fix nice!

@ghostdogpr ghostdogpr merged commit 921aa0c into ghostdogpr:series/2.x Sep 6, 2022
@SvenW SvenW deleted the bug/partial-entity-response branch September 7, 2022 05:45
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.

4 participants