Skip to content

User Projection with SpatialData MultiPoint #6121

@Christine-Schneidenwind

Description

@Christine-Schneidenwind

Is there an existing issue for this?

  • I have searched the existing issues

Product

Hot Chocolate

Describe the bug

I have enabled projection for my query and I have a MultiPoint (SpatialData) in my database

public class MyEntity 
{
    public Guid Id {get; set;}
    [Column(TypeName="geometry (multipoint)")]
    public MultiPoint MyMultiPoint { get; set;}
}
[UseProjection]
public static IQueryable<MyEntity> GetMyEntities([Service] MyDbContext dbContext) => dbContext.MyEntities;

I use an extensionType to wrap the multipoint to another type

public class GraphQLPoint
{
    public double X { get; set; }
    public double Y { get; set; }
}
[ExtendObjectType(typeof(MyEntity))]
public class MyEntityExtensions
{
  public IEnumerable<GraphQLPoint>? NewPoint([Service] IUnitOfWork unitOfWork, [Parent] MyEntity myEntity)
  {
             return myEntity.MyMultiPoint.Select(v => new GraphQLPoint {X = v.Coordinate.X, Y = v.Coordinate.Y});
  }
}

And I have an ObjectType

public class MyEntityObjectType : ObjectType<MyEntity>
{
    protected override void Configure(IObjectTypeDescriptor<Zone> descriptor)
    {
        descriptor.Field(t => t.MyMultiPoint).IsProjected()
         base.Configure(descriptor);
    }
}

Steps to reproduce

  1. If I now run a query
    query {
    myEntities {

    newPoint
    {
    x
    }
    }
    }

The value at the extension method MyMultiPoint is always null, I I will get a NullReferenceException

[ExtendObjectType(typeof(MyEntity))]
public class MyEntityExtensions
{
  public IEnumerable<GraphQLPoint>? NewPoint([Service] IUnitOfWork unitOfWork, [Parent] MyEntity myEntity)
  {
             return myEntity.**MyMultiPoint**.Select(v => new GraphQLPoint {X = v.Coordinate.X, Y = v.Coordinate.Y});
  }
}

Relevant log output

No response

Additional Context?

No response

Version

13.0.5

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions