Add batch filters - #1413
Merged
Merged
Add batch filters#1413
Conversation
A filter runs once per item, so one that queries the database made a query for every item a response returned. A list of parents, each with children, cost a query per parent and another per child. Found in a downstream API whose authorization filters made a read-access query for each row. filters.For<T>().AddBatch(projection, filter) adds a filter that decides for many items in one call. It is passed the distinct projections and returns those to include. Rows are batched across the response, not only within one list. Every resolver that filters (query, connection, navigation, navigation list and connection, single, first, and the Resolve/ResolveList extensions) now goes through Filters.Apply. Per item filters run there as before. Items with a batch filter join the execution's open batch, and the resolver returns a deferred result. GraphQL.NET completes deferred results after the other fields at the same depth, so each batch filter runs once per query depth, whichever rows returned the items. A batch that has started takes no more items, and a resolver's items join a batch together. Resolvers now return object, since the value may be a deferred result. Nothing is deferred unless a batch filter applies, so existing filters behave as before. Without an execution to share, as for ApplyFilter and ShouldInclude, a batch filter runs over the given items. Version 35.3.0.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A filter runs once per item, so one that queries the database made a query for every item a response returned. A list of parents, each with children, cost a query per parent and another per child. Found in a downstream API whose authorization filters made a read-access query for each row.
filters.For().AddBatch(projection, filter) adds a filter that decides for many items in one call. It is passed the distinct projections and returns those to include.
Rows are batched across the response, not only within one list. Every resolver that filters (query, connection, navigation, navigation list and connection, single, first, and the Resolve/ResolveList extensions) now goes through Filters.Apply. Per item filters run there as before. Items with a batch filter join the execution's open batch, and the resolver returns a deferred result. GraphQL.NET completes deferred results after the other fields at the same depth, so each batch filter runs once per query depth, whichever rows returned the items. A batch that has started takes no more items, and a resolver's items join a batch together.
Resolvers now return object, since the value may be a deferred result. Nothing is deferred unless a batch filter applies, so existing filters behave as before. Without an execution to share, as for ApplyFilter and ShouldInclude, a batch filter runs over the given items.
Version 35.3.0.