Hotchocolate: Authorize on Include authorizes all mutations

Created on 10 Feb 2020  ยท  4Comments  ยท  Source: ChilliCream/hotchocolate

Describe the bug

public class SomeType: ObjectTypeExtension<Mutation>
    {
        protected override void Configure(IObjectTypeDescriptor<Mutation> descriptor)
        {
            base.Configure(descriptor);

            descriptor.Include<SomeClass>().Authorize();
   }
}

Authorizes all mutations from Mutation class (probably on the same level as authorized ones) in 11.0.0-preview.85

Expected behavior
Authorizes mutations only from SomeClass

โ“ question

All 4 comments

hi @marcin-janiak

The IObjectTypeDescriptor is fluently implemented.
When you call descriptor.Include<SomeClass>().Authorize() then it is equivalent to

descriptor.Include<SomeClass>();
descriptor.Authorize();

So it is applied on the descriptor of the whole type.

ObjectTypeExtension Extend a type. These extensions end up in the same type.
So when you authorize one descriptor you actually authorize all.

How does SomeClass look like?
I think we can solve this problem in a different way :)

Also, have you considered to use the newer ObjectTypeExtension instead of Include?
The newer type extension API gives you more control and lets you completely decouple types.

https://hotchocolate.io/docs/schema-object-type#extension

Well, I understand how it works underneath but I have concerns about the experience of using it.
It just feels weird for me.

I noticed this during an intermediate step, then I've moved the resolvers to something like MeType which was actually my final goal.

Thanks.

@marcin-janiak Include is really on the way out .... we will depricate it with 11 since we have a much better API now to split types. With the type extensions the experience is better.

Was this page helpful?
0 / 5 - 0 ratings