solid-primitives icon indicating copy to clipboard operation
solid-primitives copied to clipboard

@solid-primitives/graphql throws error when GraphQL server returns array with errors

Open DirkWolthuis opened this issue 1 year ago • 1 comments

Hi,

I'm using a Hasura GraphQL server for my Solid project. Hasura returns the following data with a 200 if any database validation errors occur.

{
  "errors": [
    {
      "extensions": {
        "code": "constraint-violation",
        "path": "$.selectionSet.insert_proxies.args.objects[0]"
      },
      "message": "Uniqueness violation. duplicate key value violates unique constraint \"proxies_url_key\""
    }
  ]
}

If I try to access these errors by calling the result(), then an error is thrown. My guess is that the GraphQL client tries to read .data, but there is no .data. So for example:

const [result] = graphqlClient(SaveProxyWithProxyUnits);
createEffect(() => console.log(result());

results in:

Error: Unknown error
    at castError (http://127.0.0.1:3000/node_modules/.vite/deps/chunk-AGGRAV3A.js?v=9551b30e:1076:10)
    at http://127.0.0.1:3000/node_modules/.vite/deps/chunk-AGGRAV3A.js?v=9551b30e:364:84

result.state returns the error state. But for now I have no way of accessing the error information.

DirkWolthuis avatar Apr 08 '23 13:04 DirkWolthuis