-
-
Notifications
You must be signed in to change notification settings - Fork 793
Description
Is your feature request related to a problem? Please describe.
I added a @name
directive to my schema cause then I could write an extension method on IEnumTypeDescriptor<T>
to emit the original enum names as part of the schema (as opposed to having to stitch them together later). This results in a schema that looks like this:
enum DiscountType {
AGREEMENT @name(value: "Agreement")
INTERNET @name(value: "Internet")
CUSTOMERBENEFIT @name(value: "CustomerBenefit")
}
directive @name(value: String!) on ENUM_VALUE
This throws an exception when building the client, because it adds its own @name
directive.
Unhandled Exception: HotChocolate.SchemaException: The name `name` was already registered by another type. - Type: name
at HotChocolate.Configuration.TypeInitializer.EnsureNoErrors() in D:\a\1\s\src\Core\Types\Configuration\TypeInitializer.cs:line 673
at HotChocolate.Configuration.TypeInitializer.Initialize(Func`1 schemaResolver, IReadOnlySchemaOptions options) in D:\a\1\s\src\Core\Types\Configuration\TypeInitializer.cs:line 113
at HotChocolate.SchemaBuilder.Create() in D:\a\1\s\src\Core\Types\SchemaBuilder.Create.cs:line 41
at StrawberryShake.Generators.ClientGenerator.Validate() in D:\a\1\s\src\Client\Generators\ClientGenerator.cs:line 284
at StrawberryShake.Tools.GenerateCommandHandler.Compile(GenerateCommandContext context, String path, Configuration config, ClientGenerator generator, IReadOnlyList`1 documents, ICollection`1 errors) in D:\a\1\s\src\Client\dotnet-graphql\GenerateCommandHandler.cs:line 66
at StrawberryShake.Tools.CompileCommandHandlerBase`2.Compile(TCtx context, String path, Configuration configuration) in D:\a\1\s\src\Client\dotnet-graphql\CompileCommandHandlerBase.cs:line 121
at StrawberryShake.Tools.CompileCommandHandlerBase`2.Compile(TCtx context, String path) in D:\a\1\s\src\Client\dotnet-graphql\CompileCommandHandlerBase.cs:line 92
at StrawberryShake.Tools.CompileCommandHandlerBase`2.ExecuteAsync(TCtx context, CancellationToken cancellationToken) in D:\a\1\s\src\Client\dotnet-graphql\CompileCommandHandlerBase.cs:line 72
at McMaster.Extensions.CommandLineUtils.CommandLineApplication.ExecuteAsync(String[] args, CancellationToken cancellationToken)
at StrawberryShake.Tools.Program.<Main>(String[] args)
Contracts.Communication -> C:\Git\PolicyStaging\src\contracts\Contracts.Communication\bin\Debug\netstandard2.0\IfInsurance.PolicyStaging.Contracts.Communication.dll
Describe the solution you'd like
StrawberryShake should probably detect that a @name
directive already exists, and not add it's own. Same for other similar directives.
Describe alternatives you've considered
Currently I've just deleted the directive declaration line from my schema (in the client project). However, this means I can't just do dotnet graphql update
(or similar).