Open cmeeren opened 7 months ago
This is mistakenly labelled Area: F#
. The repro code is C#.
Any update on this? I'm trying to design a schema with non-nullable authorized fields and not being able to communicate that is a big issue.
If someone could point me to the problem area (i.e. where the directives are supposed to be added) I could have a crack at fixing it.
Found the issue. The directive is marked as internal. It shows up when using ISchema.Print()
but not in the API. I couldn't find any way to override this behavior either.
Got a workaround:
public sealed class PublicAuthorizeDirectiveTypeInterceptor : TypeInterceptor
{
/// <inhertidoc />
public override void OnBeforeRegisterDependencies(ITypeDiscoveryContext discoveryContext, DefinitionBase definition)
{
if (definition is DirectiveTypeDefinition dtd
&& dtd.Name == "authorize")
{
dtd.IsPublic = true;
}
base.OnBeforeRegisterDependencies(discoveryContext, definition);
}
}
services
.AddGraphQLServer()
.AddAuthorization()
.TryAddTypeInterceptor<PublicAuthorizeDirectiveTypeInterceptor>()
...
Pardon me, I've been commenting on the wrong issue.
Product
Hot Chocolate
Version
13.8.1
Link to minimal reproduction
See zip below
Steps to reproduce
Repro zip: HotChocolateBugRepro.zip
It's possible this is two separate bugs, but they are at least related:
.AddGraphQLServer().AddAuthorization()
will make an unusedApplyPolicy
enum show up in the schema. This is the case even if.TrimTypes()
is used.[Authorize]
, no@authorize
directive appears in the schema. Based on the docs and the v13 blog post, it is my understanding that this directive should appear in the schema.What is expected?
When the
@authorize
directive is not used in the schema, I expect also theApplyPolicy
enum to not be present.When using
[Authorize]
, I expect the ´@authorize´ directive to be present.What is actually happening?
The
ApplyPolicy
enum is present in the schema even if it not used, and even itTrimTypes
is used.The
@authorize
directive to be present even when using[Authorize]
.Relevant log output
No response
Additional context
No response