graphql-dotnet/conventions

Using user context with GraphQL Server?

AzureMarker opened this issue · 0 comments

I was trying out the library and found that there doesn't seem to be a good way to use it with GraphQL Server and access the user context that that library provides (via AddUserContextBuilder).

This Conventions library seems to only take in the context once you create an executor, but that's handled internally by the Server library. I would expect that the Conventions library would have some way to either mark or recognize a parameter as provided by an internal process like the Server library. Maybe there needs to be an explicit integration package between Conventions and Server.

With this branch of my project I get the following error on startup:

Unhandled exception. System.ArgumentOutOfRangeException: A type name can not be null or empty. (Parameter 'name')
   at GraphQL.Utilities.NameValidator.ValidateNameNotNull(String name, String type) in /_/src/GraphQL/Utilities/NameValidator.cs:line 31
   at GraphQL.Utilities.NameValidator.ValidateName(String name, String type) in /_/src/GraphQL/Utilities/NameValidator.cs:line 13
   at GraphQL.Types.GraphType.SetName(String name, Boolean validate) in /_/src/GraphQL/Types/GraphType.cs:line 49
   at GraphQL.Types.GraphType.set_Name(String value) in /_/src/GraphQL/Types/GraphType.cs:line 65
   at GraphQL.Conventions.Adapters.GraphTypeAdapter.ConstructType[TReturnType](Type template, GraphTypeInfo typeInfo)
   at GraphQL.Conventions.Adapters.GraphTypeAdapter.ConstructInputType(GraphTypeInfo typeInfo)
   at GraphQL.Conventions.Adapters.GraphTypeAdapter.GetComplexType(GraphTypeInfo typeInfo)
   at GraphQL.Conventions.Adapters.GraphTypeAdapter.DeriveType(GraphTypeInfo typeInfo)
   at GraphQL.Conventions.Adapters.GraphTypeAdapter.GetType(GraphTypeInfo typeInfo)
   at GraphQL.Conventions.Adapters.GraphTypeAdapter.DeriveField(GraphFieldInfo fieldInfo)
   at System.Linq.Enumerable.SelectListIterator`2.MoveNext()
   at GraphQL.Conventions.Adapters.GraphTypeAdapter.DeriveFields(GraphTypeInfo typeInfo, IComplexGraphType graphType)
   at GraphQL.Conventions.Adapters.GraphTypeAdapter.ConstructInterfaceType(GraphTypeInfo typeInfo)
   at GraphQL.Conventions.Adapters.GraphTypeAdapter.GetComplexType(GraphTypeInfo typeInfo)
   at GraphQL.Conventions.Adapters.GraphTypeAdapter.DeriveType(GraphTypeInfo typeInfo)
   at GraphQL.Conventions.Adapters.GraphTypeAdapter.GetType(GraphTypeInfo typeInfo)
   at GraphQL.Conventions.Adapters.GraphTypeAdapter.DeriveArgument(GraphArgumentInfo argumentInfo)
   at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()
   at GraphQL.Types.QueryArguments..ctor(IEnumerable`1 list) in /_/src/GraphQL/Types/QueryArguments.cs:line 20
   at GraphQL.Conventions.Adapters.GraphTypeAdapter.DeriveField(GraphFieldInfo fieldInfo)
   at System.Linq.Enumerable.SelectListIterator`2.MoveNext()
   at GraphQL.Conventions.Adapters.GraphTypeAdapter.DeriveFields(GraphTypeInfo typeInfo, IComplexGraphType graphType)
   at GraphQL.Conventions.Adapters.GraphTypeAdapter.ConstructOutputType(GraphTypeInfo typeInfo)
   at GraphQL.Conventions.Adapters.GraphTypeAdapter.GetComplexType(GraphTypeInfo typeInfo)
   at GraphQL.Conventions.Adapters.GraphTypeAdapter.DeriveType(GraphTypeInfo typeInfo)
   at GraphQL.Conventions.Adapters.GraphTypeAdapter.DeriveSchema(GraphSchemaInfo schemaInfo)
   at GraphQL.Conventions.Builders.SchemaConstructor`2.Build(TypeInfo[] schemaTypes)
   at GraphQL.Conventions.Builders.SchemaConstructor`2.Build(Type[] schemaTypes)
   at GraphQL.Conventions.GraphQLEngine.BuildSchema(SchemaPrinterOptions options, Type[] types)
   at GraphQL.Conventions.GraphQLEngine.BuildSchema(Type[] types)
   at Forte.NET.Startup.ConfigureServices(IServiceCollection services) in /home/mark/media/Forte/Forte.NET/Forte.NET/Startup.cs:line 27
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.InvokeCore(Object instance, IServiceCollection services)
   at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.<>c__DisplayClass9_0.g__Startup|0(IServiceCollection serviceCollection)
   at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.Invoke(Object instance, IServiceCollection services)
   at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.<>c__DisplayClass8_0.b__0(IServiceCollection services)
   at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.UseStartup(Type startupType, HostBuilderContext context, IServiceCollection services, Object instance)
   at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.<>c__DisplayClass13_0.b__0(HostBuilderContext context, IServiceCollection services)
   at Microsoft.Extensions.Hosting.HostBuilder.CreateServiceProvider()
   at Microsoft.Extensions.Hosting.HostBuilder.Build()
   at Forte.NET.Program.Main(String[] args) in /home/mark/media/Forte/Forte.NET/Forte.NET/Program.cs:line 7

The notable files are Startup.cs, Query.cs, and ForteDbContext.cs.