-
Notifications
You must be signed in to change notification settings - Fork 86
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
graphql type signature doesn't match its result #50
Comments
Thanks for the well written report! That code has been written like that since before the migration to TypeScript. If I would change the return value to |
I personally would just change the type of Ideally I'd like to see the implementation match the current type information in the sense that it will not throw an exception, but just return Returning |
Just to give an impression how I'm now handling the graphql call: |
Thanks, for the explanation, I will try and look into it |
Thanks @wolfy1339. The types are wrong, Sorry for the trouble :( |
🎉 This issue has been resolved in version 4.0.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
The type signature of the
graphql
call says the result is aGraphQlQueryResponse
, which is defined as:graphql.js/src/types.ts
Lines 33 to 48 in c1fa150
A object that has a
data
attribute and an optionalerrors
attribute.However, the implementation of the
graphql
call returns something entirely different:graphql.js/src/graphql.ts
Lines 41 to 49 in c1fa150
It returns the contents of the
data
attribute and passes the errors by throwing an exception.This behaviour is very confusing, as the type information is lying about the implementation. This resulted in some downtime on my application after an update of probot, as I presumed in my tests and mocks that the type information is correct. Refactorings were made to accomodate the new type signature of the graphql call, however the
graphql
call is the part that is mocked in tests.Since this is something that I think more people would run into, I'm a bit doubtful the above findings are indeed correct. This problem did not seem to be reported yet? Am I doing something wrong?
I thought the implementation would need to look something like:
The text was updated successfully, but these errors were encountered: