Zaid-Ajaj / Snowflaqe

A dotnet CLI to generate type-safe GraphQL clients for F# and Fable with automatic deserialization, static query verification and type checking
MIT License
154 stars 25 forks source link

Complex object for errorType? #55

Closed bdaniel7 closed 2 years ago

bdaniel7 commented 2 years ago

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 commented 2 years ago

Yes! See the docs here

Zaid-Ajaj commented 2 years ago

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 commented 2 years ago

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

bdaniel7 commented 2 years ago

For now I removed the custom errorType definition.

Zaid-Ajaj commented 2 years ago

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

bdaniel7 commented 2 years ago

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.