Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support for projection columns in the model?

See original GitHub issue

I 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:closed
  • Created a year ago
  • Comments:16 (10 by maintainers)

github_iconTop GitHub Comments

lukemurraycommented, Sep 11, 2022

That hook would also allow people to add TagWith for #169

lukemurraycommented, Sep 11, 2022

Was just looking at this as your comment came through.

I played with something like this ages ago to aid reuse

        public static Expression<Func<Task, bool>> ComputedProp_Expression = task => task.IsActive && task.Assignee != null;
        public bool ComputedProp => IsActive && Assignee != null;

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 any Decompile() or WithTranslation() type things.

Read more comments on GitHub >

github_iconTop Results From Across the Web

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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found