graphqurl icon indicating copy to clipboard operation
graphqurl copied to clipboard

throw elegant errors

Open wawhal opened this issue 5 years ago • 6 comments

Errors should be of the format:

{
    "errors" : [
         ....
    ]
}

wawhal avatar Aug 03 '18 10:08 wawhal

hey, can you tell me what I need to do in this issue .? @wawhal

kartikpandey2 avatar Oct 03 '18 18:10 kartikpandey2

@kartikpandey2 a lot of custom errors are thrown and some might even show the stack trace. Every error should be of the form described above if graphqurl is being imported as a node library.

Also, proper error messages should be provided throughout the library. For example. if you run the command with a random URL, say

$ gq http://somerandom.url/graphql -q 'query { test { field } }'

It throws a large ugly error with a stack trace. That should never happen. Every error should be informative for the user.

wawhal avatar Oct 04 '18 08:10 wawhal

@wawhal thanks, I am working on this issue.

kartikpandey2 avatar Oct 04 '18 17:10 kartikpandey2

@wawhal I have some doubts The error should be displayed as error : ['some error'] or it should be of type array and should only be displayed as 'Some error' (informative error message and stack trace) and here error include CLI errors .? I tried running following query gq http://somerandom.url/graphql -q 'query { test { field } }' It is throwing informative error ii.e,» Error: Unexpected arguments: {, test, {, field, }, }' » See more help with --help So I am confused 😅 , How to solve this issue can you guide me.

kartikpandey2 avatar Oct 05 '18 21:10 kartikpandey2

Error: <informative-message> should be fine if it is a custom error. If the error comes from the server, it should be of the above type.

In case of gq http://somerandom.url/graphql -q 'query { test { field } }', it should throw Error: Invalid GraphQL endpoint or something like that.

wawhal avatar Oct 06 '18 09:10 wawhal

@wawhal Ok

kartikpandey2 avatar Oct 07 '18 11:10 kartikpandey2