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

Spanned arguments #1209

Merged
merged 5 commits into from
Nov 9, 2023
Merged

Conversation

audunhalland
Copy link
Contributor

@audunhalland audunhalland commented Nov 9, 2023

Continued from #1206

This change improves diagnostics when performing manual/domain-specific post-validation of arguments using LookAheadArguments. In the case of an error, the produced error message may be able to refer to the exact position in the problematic GraphQL arguments.

On an unrelated note, I noticed LookAheadArgument does a deep/greedy transform of the InputValue to perform variable substitution. A potential improvement to this is to only do this lazily for each expansion step, i.e. the LookAheadArgument privately keeps a reference to its InputValue and the variable table and somehow exposes a LookAhead interface on top of this.

@@ -52,15 +52,15 @@ impl Span {

/// Data structure used to wrap items into a [`Span`].
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub struct Spanning<T> {
pub struct Spanning<T, Sp = Span> {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The added generic argument probably influences how this is documented, but not sure.

The point of the generic is to avoid making a separate type like BorrowedSpanning, but I'm up for improvement suggestions.

The ability to borrow a Span can lead to slightly more performant code in various places. Currently only in look_ahead, other future suggestions are e.g. the input validation rules.

@tyranron tyranron added enhancement Improvement of existing features or bugfix k::api Related to API (application interface) k::refactor Refactoring, technical debt elimination and other improvements of existing code base area::parsing Related to GraphQL parsing semver::breaking Breaking change in terms of SemVer and removed k::refactor Refactoring, technical debt elimination and other improvements of existing code base labels Nov 9, 2023
@tyranron tyranron added this to the 0.16.0 milestone Nov 9, 2023
Copy link
Member

@tyranron tyranron left a comment

Choose a reason for hiding this comment

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

@audunhalland thanks!

juniper/src/schema/meta.rs Outdated Show resolved Hide resolved
@tyranron tyranron merged commit e75cf26 into graphql-rust:master Nov 9, 2023
182 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area::parsing Related to GraphQL parsing enhancement Improvement of existing features or bugfix k::api Related to API (application interface) semver::breaking Breaking change in terms of SemVer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants