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

feat(dart_frog): add tryRead method to RequestContext #1652

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

mtwichel
Copy link
Contributor

Status

READY

Description

Closes #1651. Adds a tryRead function to the RequestContext that works exactly like read, but instead of throwing a StateError when a provided value isn't found, it return null. This is useful for objects that may or not be provided depending on certain factors, like a User being provided only if they are authenticated. The change has also been reflected in the docs site.

Type of Change

  • ✨ New feature (non-breaking change which adds functionality)
  • 🛠️ Bug fix (non-breaking change which fixes an issue)
  • ❌ Breaking change (fix or feature that would cause existing functionality to change)
  • 🧹 Code refactor
  • ✅ Build configuration change
  • 📝 Documentation
  • 🗑️ Chore

@mtwichel mtwichel requested a review from a team as a code owner December 19, 2024 19:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Review
Development

Successfully merging this pull request may close these issues.

feat: add tryRead<T> function to simplify reading values only if they exist instead
1 participant