ChilliCream / ChilliCream/graphql-platform
Multi target directive descriptor attributes
@michaelstaib is already working on this.
Since Oct 12, 2023.
- Dominant language
- C#
- Stars
- 5.8k
- Forks
- 810
- Avg merge
- 15h 39m
- Merged PRs (30d)
- 98
Description
Product
Hot Chocolate
Is your feature request related to a problem?
Attributes are convenient way to apply directives in a code-first approach. HotChocolate provides a convenient built-in mechanism that automatically configures type specific DescriptorAttribute.
This works great for directives targeting single location (e.g. FIELD_DEFINITION) but is problematic if we have multiple targets. Built-in HotChocolate directives (TagAttribute, AuthorizeAttribute work around this problem by extending DescriptorAttribute.
Unfortunately this method doesn't work for external projects as DescriptorAttribute currently defines an internal method which means it is not possible to extend it outside of HotChocolate repository.
protected internal abstract void TryConfigure(
IDescriptorContext context,
IDescriptor descriptor,
ICustomAttributeProvider element);
As a result we currently have two workarounds
- define location specific attribute, e.g.
TagFieldAttribute/TagObjectAttribute(which for something like@tagwould imply a LOT of different attributes) - extend base
Attribute, bypassHotChocolatebuilt-in logic and provide custom logic to apply directives in a customTypeInterceptor
The solution you'd like
The simplest solution would be to allow users extend DescriptorAttribute.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.