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

Execution Context errors #3439

Open
patrick91 opened this issue Apr 5, 2024 · 1 comment
Open

Execution Context errors #3439

patrick91 opened this issue Apr 5, 2024 · 1 comment

Comments

@patrick91
Copy link
Member

patrick91 commented Apr 5, 2024

What is self.execution_context.errors on an extension, is it needed? (we have errors on the result)

Related: StellateHQ/stellate-strawberry#6

Upvote & Fund

  • We're using Polar.sh so you can upvote and help fund this issue.
  • We receive the funding once the issue is completed & confirmed by you.
  • Thank you in advance for helping prioritize & fund our backlog.
Fund with Polar
@DoctorJohn
Copy link
Member

DoctorJohn commented Jul 4, 2024

Good point. I just spend some time looking at the code. In a nutshell: execution_context.result is not available during the execution of early extension hooks such the parsing hook.

Longer explanation:

During execution, the execution context is first created in the schema.execute and schema.execute_sync methods. At this point the execution_context.result is still None.

https://github.com/strawberry-graphql/strawberry/blob/main/strawberry/schema/schema.py#L257-L264

Next the operation, parsing and validation hooks of all extensions are called. If they catch any errors (for example while parsing the query) they add it to execution_context.errors because executon_context.result(.errors) is not available yet.

https://github.com/strawberry-graphql/strawberry/blob/main/strawberry/schema/execute.py#L103-L117

One all extension hooks are done execution_context.errors is copied to execution_context.result.errors:

https://github.com/strawberry-graphql/strawberry/blob/main/strawberry/schema/execute.py#L173-L177

I agree it would be much cleaner and less error-prone if only one of them would be available to extensions.

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

No branches or pull requests

2 participants