strawberry
strawberry copied to clipboard
Initial implementation of friendlier errors
I'll add a proper description later, this PR is just for testing the CI steps.
Related: #2107
TODO:
- [x] assert that documentation exists (via pytest)
- [x] make all of this optional (flag and checking for imports)
- [x] Don't fail bad if ast parsing fails (for example with dynamic code)
- [x] don't add libcst as main dependency
- [x] print standard exception if we can't find the source (?)
- [x] redirect from errors.strawberry.rocks
Future release:
- [ ] Errors in wasm (if libcst works)
Maybe:
- [ ] custom flake8 plugin to disable pytest.raises with StrawberryExceptions
Codecov Report
Merging #2027 (81ab49e) into main (39edd31) will decrease coverage by
0.06%. The diff coverage is96.71%.
Additional details and impacted files
@@ Coverage Diff @@
## main #2027 +/- ##
==========================================
- Coverage 97.87% 97.80% -0.07%
==========================================
Files 163 180 +17
Lines 6688 7299 +611
Branches 1251 1316 +65
==========================================
+ Hits 6546 7139 +593
- Misses 69 76 +7
- Partials 73 84 +11
/pre-release
Pre-release
:wave:
Pre-release 0.145.0.dev.1670175214 [46f9ee1d244f6d929ea3dd3e5125058d0c3a8099] has been released on PyPi! :rocket: You can try it by doing:
poetry add strawberry-graphql==0.145.0.dev.1670175214
Pre-release
:wave:
Pre-release 0.127.0.dev.1661177678 [1c694722e2c8ac628ec8fb603029a1adf0c67aa2] has been released on PyPi! :rocket: You can try it by doing:
poetry add strawberry-graphql==0.127.0.dev.1661177678
/pre-release
Hi 👋 You can find a preview of the docs here:
https://strawberry.rocks/docs/pr/2027/types/exceptions https://strawberry.rocks/docs/pr/2027/errors https://strawberry.rocks/docs/pr/2027/errors/_template https://strawberry.rocks/docs/pr/2027/errors/invalid-argument-type https://strawberry.rocks/docs/pr/2027/errors/invalid-type-for-union-merge https://strawberry.rocks/docs/pr/2027/errors/invalid-union-type https://strawberry.rocks/docs/pr/2027/errors/missing-arguments-annotations https://strawberry.rocks/docs/pr/2027/errors/missing-field-annotation https://strawberry.rocks/docs/pr/2027/errors/missing-return-annotation https://strawberry.rocks/docs/pr/2027/errors/object-is-not-an-enum https://strawberry.rocks/docs/pr/2027/errors/object-is-not-class https://strawberry.rocks/docs/pr/2027/errors/private-strawberry-field https://strawberry.rocks/docs/pr/2027/errors/scalar-already-registered
Thanks for adding the RELEASE.md file!

Here's a preview of the changelog:
This release introduced improved errors! Now, when you have a syntax error in your code, you'll get a nice error message with a line number and a pointer to the exact location of the error. ✨
This is a huge improvement over the previous behavior, which was providing a stack trace with no clear indication of where the error was. 🙈
You can enable rich errors by installing Strawberry with the cli extra:
pip install strawberry-graphql[cli]
Here's the preview release card for twitter:

Here's the tweet text:
🆕 Release (next) is out! Thanks to @patrick91 for the PR 👏
Get it here 👉 https://github.com/strawberry-graphql/strawberry/releases/tag/(next)
/pre-release
from discord:
we should make this error better, if not already done here:
import strawberry
from strawberry.scalars import JSON
strawberry.union(
name='NamedUnion',
types=(
# some other types
JSON,
),
)
AttributeError: 'ScalarWrapper' object has no attribute 'name'. Did you mean: 'ne'.
/pre-release
/pre-release
/pre-release
/pre-release