Support for projection columns in the model?
See original GitHub issueI have some logic that I want to reuse between queries and mutations. Simple example would be calculating if an entity can be deleted (which can be a complicated nested query that checks child items).
I could use ResolveWithService to do this and pass in all the items it needs, but that doesn’t feel that reusable in the muation (eg load the item and double check it can be deleted first).
It occurred to me taht the following might be an elegant solution (although keen to hear if you have other ways you normally do this).
public class Order {
//properties here
public Expression<Func<ProductOrder, bool>> CanDelete => (x) => x.StatusId == ProductOrderStatusEnum.OnHold;
}
That way we can map it to a Resolve() function in the query, but if I wanted to access it elsewhere the logic is (potentially) executable/translatable to SQL.
research notes
Issue Analytics
- State:
- Created a year ago
- Comments:16 (10 by maintainers)
Top Results From Across the Web
PROJECTION_COLUMNS
Column Name Data Type Description
PROJECTION_COLUMN_NAME VARCHAR The projection column name.
TABLE_NAME VARCHAR The table name that contains the projection.
TABLE_COLUMN_NAME VARCHAR The projection's corresponding table...
Read more >Projections - What is Gantry?
Projections are computed columns used to help interpret unstructured data. ... projection to understand how many words are in the input to the...
Read more >Projections | ClickHouse Docs
Projections store data in a format that optimizes query execution, this feature is useful for: Running queries on a column that is not...
Read more >Create a Calculated Column in a Projection Operator
In the properties panel of the projection operator, choose (Add New Calculated Column) in the Columns section. · Provide a name and data...
Read more >Output Column Projection - Aster Execution Engine
Output column projection describes the set of columns that are produced by a SQL-MapReduce function and are needed in the query. By specifying...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
That hook would also allow people to add
TagWith
for #169Was just looking at this as your comment came through.
I played with something like this ages ago to aid reuse
Where EntityGraphQL would look for that expression property to use the expression instead of the computed property.
But I hate that you had to duplicate the logic. Now source generators could create those for you which I think is nice. Could easily provide a extension method to do the translation on a normal ling query when using in mutations etc.
Do agree that it might be outside the scope of the project (although I would like a nice way to reuse some logic).
I have plans for a
[GraphQLField]
to allow a different way of making fields with arguments etc. So perhaps as part of that need to make sure it works well with some of the other libraries.Today you could add the Nein Linq fields manually with
schema.AddField(...)
and a quick win would be a hook on the final execution of the expression where you could than hook in anyDecompile()
orWithTranslation()
type things.