Is there an existing issue for this?
Product
Hot Chocolate
Describe the bug
I am trying to use spatial types with EF Core from postgres (postgis) database.
I have the following entity:
public class Region
{
public required Guid Id { get; set; }
public required Geometry? Geometry { get; set; }
public required string AgreementNumber { get; set; }
public required DateTime AgreementDate { get; set; }
public required string Status { get; set; }
}
In the mapping:
entity.Property(e => e.Geometry)
.HasColumnName("geom")
.HasColumnType("geometry");
And a query type:
[QueryType]
public class RegionQueries
{
[UseProjection]
[UseFiltering]
public IQueryable<Region> GetRegions(ApplicationDbContext dbContext)
{
return dbContext.Regions;
}
}
I register GraphQL in DI as follows:
services
.AddGraphQLServer()
.AddAuthorization()
.AddQueryType()
.AddMutationType()
.AddSpatialTypes()
.AddFiltering()
.AddProjections()
.AddSpatialFiltering()
.AddSpatialProjections()
.AddSorting()
// Custom queries and mutations
.AddUserTypes()
.AddRegionTypes()
.RegisterDbContext<ApplicationDbContext>();
When I start my asp.net core app I get error on startup when trying to create a graphql executor:
var executor = await app.Services.GetRequestExecutorAsync();
await File.WriteAllTextAsync("schema.graphql", executor.Schema.ToString());
Error:
HotChocolate.SchemaException: For more details look at the `Errors` property.
1. The type 'System.Byte*' may not be used as a type argument.
at HotChocolate.Configuration.TypeInitializer.DiscoverTypes()
at HotChocolate.Configuration.TypeInitializer.Initialize()
Steps to reproduce
- Install the following Nuget packages:
<PackageReference Include="HotChocolate.AspNetCore" Version="13.6.1" />
<PackageReference Include="HotChocolate.AspNetCore.Authorization" Version="13.6.1" />
<PackageReference Include="HotChocolate.Data" Version="13.6.1" />
<PackageReference Include="HotChocolate.Types.Analyzers" Version="13.6.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="HotChocolate.Types.Spatial" Version="13.6.1" />
<PackageReference Include="NetTopologySuite" Version="2.5.0" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.11" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL.NetTopologySuite" Version="7.0.11" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.12">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
-
Create an entity, mapping and EfCore Dbcontext with Geometry type
-
Create GraphQL query that returns IQueryable with entity that has Geometry type
-
Initialize graphql to perform schema creation
-
Get exception
Relevant log output
HotChocolate.SchemaException: For more details look at the `Errors` property.
1. The type 'System.Byte*' may not be used as a type argument.
at HotChocolate.Configuration.TypeInitializer.DiscoverTypes()
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)
at Program.<Main>$(String[] args) in ...
Errors property has:
{
"message": "The type 'System.Byte*' may not be used as a type argument.",
"extensions": {},
"exception": "The type 'System.Byte*' may not be used as a type argument."
}
System.ArgumentException: The type 'System.Byte*' may not be used as a type argument.
at System.RuntimeType.ThrowIfTypeNeverValidGenericArgument(RuntimeType type)
at System.RuntimeType.MakeGenericType(Type[] instantiation)
at HotChocolate.Configuration.TypeRefHelper.CreateTypeRef(ITypeInspector typeInspector, Type schemaType, TypeDiscoveryInfo typeInfo, TypeReference originalTypeRef)
at HotChocolate.Configuration.DefaultTypeDiscoveryHandler.TryInferType(TypeReference typeReference, TypeDiscoveryInfo typeInfo, TypeReference[]& schemaTypeRefs)
at HotChocolate.Configuration.TypeDiscoveryDescriptorContextExtensions.TryInferSchemaType(IDescriptorContext context, TypeReference unresolvedTypeRef, TypeReference[]& schemaTypeRefs)
at HotChocolate.Configuration.TypeDiscoverer.TryInferTypes()
at HotChocolate.Configuration.TypeDiscoverer.DiscoverTypes()
Additional Context?
I use postgis in docker on windows containers, image: postgis/postgis:16-3.4
Version
13.6.1
Is there an existing issue for this?
Product
Hot Chocolate
Describe the bug
I am trying to use spatial types with EF Core from postgres (postgis) database.
I have the following entity:
In the mapping:
I register GraphQL in DI as follows:
When I start my asp.net core app I get error on startup when trying to create a graphql executor:
Error:
Steps to reproduce
Create an entity, mapping and EfCore Dbcontext with Geometry type
Create GraphQL query that returns IQueryable with entity that has Geometry type
Initialize graphql to perform schema creation
Get exception
Relevant log output
Additional Context?
I use postgis in docker on windows containers, image: postgis/postgis:16-3.4
Version
13.6.1