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

ValidatePipelineOrder=false wont work #5883

Closed
1 task done
barnuri-cp opened this issue Feb 22, 2023 · 8 comments · Fixed by #6123
Closed
1 task done

ValidatePipelineOrder=false wont work #5883

barnuri-cp opened this issue Feb 22, 2023 · 8 comments · Fixed by #6123

Comments

@barnuri-cp
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Product

Hot Chocolate

Describe the bug

when setting ValidatePipelineOrder=false, its probably not populate to MiddlewareValidationTypeInterceptor
because it keep throwing errors of invalid order

Steps to reproduce

var graphqlBuilder = servicesCollection.AddGraphQLServer();
graphqlBuilder = graphqlBuilder.AddProjections();
graphqlBuilder = graphqlBuilder.AddFiltering();
graphqlBuilder = graphqlBuilder.AddSorting();
graphqlBuilder = graphqlBuilder.SetOptions(new() {ValidatePipelineOrder =false});
graphqlBuilder = graphqlBuilder.ModifyOptions(c => c.ValidatePipelineOrder = false);

[UseDbContext(typeof(User))]
[UseSorting]
[UsePaging]
[UseProjection]
[UseFiltering]
public IQueryable GetUser([Service] Repo repository) => repository.Users;

Relevant log output

No response

Additional Context?

No response

Version

13

@PascalSenn
Copy link
Member

@barnuri-cp
Reproduced, Workaround, do not use SetOptions just use ModifyOptions

Also, why do you want to do this?

@barnuri-cp
Copy link
Author

@PascalSenn im writing a feature to distinct the result of IQueryable, and i put it after the projections and its works good, but the sort happen before, and i need it after the distict because i wanted the distinct results to be sorted so sort need to be in the end

@michaelstaib
Copy link
Member

It also will not work... sorting cannot work after paging since paging is not outputing a list or queryable.

@michaelstaib
Copy link
Member

But you could handle the order in your resolver.

@barnuri-cp
Copy link
Author

@michaelstaib can you give me an example ? i want one resolver for the whole app, dont want to config it each method

@michaelstaib
Copy link
Member

How do you want to have one resolver for different types?

HC 13 allows you tow wrap attributes in attributes and introduce a new pipeline in there. The new pipeline can do the apply on the queryable.

@barnuri-cp
Copy link
Author

@michaelstaib
yeah i want to make it generic, dont wont to work hard it every type, like all other works
for example if i had a way to just receive the IQueryable before everything else is running i can do it generic
IQueryable q
q = q.Filter(context).Projection(context).Distinct().Sort(context)

@barnuri-cp
Copy link
Author

barnuri-cp commented Feb 22, 2023

@michaelstaib nice ! find that

public class UseSearchAttribute : DescriptorAttribute
{
    protected override void TryConfigure(IDescriptorContext context, IDescriptor descriptor, ICustomAttributeProvider element)
    {
        ApplyAttribute(context, descriptor, element, new UseSortingAttribute());
        ApplyAttribute(context, descriptor, element, new UsePagingAttribute());
        ApplyAttribute(context, descriptor, element, new UseProjectionAttribute());
        ApplyAttribute(context, descriptor, element, new UseFilteringAttribute());
    }
}

thanks for the help and the quick response !!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants