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

Complex object for errorType? #55

Closed
bdaniel7 opened this issue Nov 4, 2021 · 6 comments
Closed

Complex object for errorType? #55

bdaniel7 opened this issue Nov 4, 2021 · 6 comments

Comments

@bdaniel7
Copy link

bdaniel7 commented Nov 4, 2021

Is there a way to configure the errorType to be a more complex object?
Like an array/list of error objects.

"errors": [
    {
      "message": "Invalid cursor provided for the after parameter: a",
      "locations": [{ "line": 2, "column": 3 }],
      "path": ["vessels"],
      "extensions": {
        "code": "BAD_USER_INPUT"
      }
    }
  ]
@Zaid-Ajaj
Copy link
Owner

Yes! See the docs here

@Zaid-Ajaj
Copy link
Owner

In your case, it would be

"errorType": {
        "CustomErrorType": {
            "message": "string"
            "path": "string list"
            "extensions": "dictionary<string, string>"
        }
}

As for locations, there isn't a generic way to describe such type (list of other complex objects) but it should be doable to add if you REALLY need it

@Zaid-Ajaj
Copy link
Owner

I believe this is resolved as well? I'll close the issue, please re-open if the problem persists

@bdaniel7
Copy link
Author

bdaniel7 commented Nov 8, 2021

For now I removed the custom errorType definition.

@Zaid-Ajaj
Copy link
Owner

@bdaniel7 Didn't the proposed solution work for you?

@bdaniel7
Copy link
Author

bdaniel7 commented Nov 8, 2021

Hmm, I see now that it does fill the error object:

{ message =
   "Cannot query field "updateTimestamps" on type "Vessel". Did you mean "updateTimestamp"?"
  path = null
  extensions = seq [[code, GRAPHQL_VALIDATION_FAILED]] }

Ok, I will use the custom error object as you recommended, thank you.

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

No branches or pull requests

2 participants