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

Invalid schema name error should be more descriptive #7934

Closed
maurice-freitag opened this issue Jan 20, 2025 · 0 comments · Fixed by #7939
Closed

Invalid schema name error should be more descriptive #7934

maurice-freitag opened this issue Jan 20, 2025 · 0 comments · Fixed by #7939
Assignees
Milestone

Comments

@maurice-freitag
Copy link

Product

Hot Chocolate

Is your feature request related to a problem?

When constructing a schema with an invalid name we get the following error:

 An unhandled exception has occurred while executing the request.
      System.ArgumentException: The specified name is not a valid GraphQL name. (Parameter 'value')
         at HotChocolate.Utilities.NameUtils.EnsureGraphQLName(String name, String argumentName)
         at HotChocolate.Types.Descriptors.Definitions.DefinitionBase.set_Name(String value)
         at HotChocolate.Execution.RequestExecutorResolver.SetSchemaNameInterceptor.OnBeforeCompleteName(ITypeCompletionContext completionContext, DefinitionBase definition)
         at HotChocolate.Configuration.AggregateTypeInterceptor.OnBeforeCompleteName(ITypeCompletionContext completionContext, DefinitionBase definition)
         at HotChocolate.Types.TypeSystemObjectBase`1.OnBeforeCompleteName(ITypeCompletionContext context, DefinitionBase definition)
         at HotChocolate.Types.TypeSystemObjectBase`1.CompleteName(ITypeCompletionContext context)
         at HotChocolate.Configuration.TypeInitializer.CompleteTypeName(RegisteredType registeredType)
         at HotChocolate.Configuration.TypeInitializer.ProcessTypes(TypeDependencyFulfilled fulfilled, Func`2 action)
         at HotChocolate.Configuration.TypeInitializer.CompleteNames()
         at HotChocolate.Configuration.TypeInitializer.Initialize()
         at HotChocolate.SchemaBuilder.Setup.InitializeTypes(SchemaBuilder builder, IDescriptorContext context, IReadOnlyList`1 types)
         at HotChocolate.SchemaBuilder.Setup.Create(SchemaBuilder builder, LazySchema lazySchema, IDescriptorContext context)
         at HotChocolate.SchemaBuilder.Create(IDescriptorContext context)
         at HotChocolate.SchemaBuilder.HotChocolate.ISchemaBuilder.Create(IDescriptorContext context)
         at HotChocolate.Execution.RequestExecutorResolver.CreateSchemaAsync(ConfigurationContext context, RequestExecutorSetup setup, RequestExecutorOptions executorOptions, IServiceProvider schemaServices, TypeModuleChangeMonitor typeModuleChangeMonitor, CancellationToken cancellationToken)
         at HotChocolate.Execution.RequestExecutorResolver.CreateSchemaServicesAsync(ConfigurationContext context, RequestExecutorSetup setup, CancellationToken cancellationToken)
         at HotChocolate.Execution.RequestExecutorResolver.GetRequestExecutorNoLockAsync(String schemaName, CancellationToken cancellationToken)
         at HotChocolate.Execution.RequestExecutorResolver.GetRequestExecutorAsync(String schemaName, CancellationToken cancellationToken)

Debugging this error would be a lot easier if the invalid value would be logged as well.

The solution you'd like

In NameUtils.EnsureGraphQLName add the invalid value to the exception message.

throw new ArgumentException(string.Format(NameUtils_InvalidGraphQLName, name), argumentName);

Change the string from The specified name is not a valid GraphQL name. to {0} is not a valid GraphQL name..

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.

2 participants