Skip to content
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

Fix ParserCache Syntax Errors #3256

Conversation

imconnorngl
Copy link
Contributor

@imconnorngl imconnorngl commented Nov 27, 2023

Description

ParserCache does not catch SyntaxErrors in the GraphQL input.

Expected behaviour can be seen in strawberry.schema.execute.

Types of Changes

  • Core
  • Bugfix
  • New feature
  • Enhancement/optimization
  • Documentation

Issues Fixed or Closed by This PR

N/A

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • I have tested the changes and verified that they work and don't break anything (as well as I can manage).

@botberry
Copy link
Member

botberry commented Nov 27, 2023

Hi, thanks for contributing to Strawberry 🍓!

We noticed that this PR is missing a RELEASE.md file. We use that to automatically do releases here on GitHub and, most importantly, to PyPI!

So as soon as this PR is merged, a release will be made 🚀.

Here's an example of RELEASE.md:

Release type: patch

Description of the changes, ideally with some examples, if adding a new feature.

Release type can be one of patch, minor or major. We use semver, so make sure to pick the appropriate type. If in doubt feel free to ask :)

Here's the tweet text:

🆕 Release (next) is out! Thanks to @imconnorngl for the PR 👏

Get it here 👉 https://beta.strawberry.rocks/release/(next)

Copy link

codecov bot commented Nov 27, 2023

Codecov Report

Merging #3256 (a13862b) into main (a90dea2) will increase coverage by 0.23%.
The diff coverage is 94.11%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3256      +/-   ##
==========================================
+ Coverage   96.36%   96.60%   +0.23%     
==========================================
  Files         482      482              
  Lines       29952    29970      +18     
  Branches     3690     3695       +5     
==========================================
+ Hits        28863    28952      +89     
+ Misses        898      834      -64     
+ Partials      191      184       -7     

@patrick91
Copy link
Member

hi @imconnorngl! could you add a test for this? 😊

Copy link

codspeed-hq bot commented Nov 27, 2023

CodSpeed Performance Report

Merging #3256 will not alter performance

Comparing imconnorngl:parser-cache-syntax-catch (a13862b) with main (a90dea2)

Summary

✅ 12 untouched benchmarks

@imconnorngl
Copy link
Contributor Author

hi @imconnorngl! could you add a test for this? 😊

Hi :) Added those, let me know if any of that is wrong! First time contributing here but just wanted to say it's a very very nice experience!

One check is failing, I've probably done something wrong! Let me know if I need to fix anything :)

Copy link
Member

@patrick91 patrick91 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is almost ready to go, the failing check is because we are missing a release file 😊

See this comment: #3256 (comment)


result = schema.execute_sync(query)

assert result.errors
Copy link
Member

@patrick91 patrick91 Nov 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we also assert the value of the error here? 😊

@strawberry.type
class Query:
@strawberry.field
def hello(self) -> str:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def hello(self) -> str:
def hello(self) -> str: # pragma: no cover

this should silence the warning below

@patrick91
Copy link
Member

After chatting with @imconnorngl we noticed that this issue can be fixed by #3217 so I pulled the test in there 😊

I'll close this PR, and make a pre-release :)

@patrick91 patrick91 closed this Nov 27, 2023
@imconnorngl imconnorngl mentioned this pull request Nov 27, 2023
11 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants