ByteArrayType for Entity Framework RowVersion/[TimeStamp] #3132
-
Hi, Further question I can't workout but hopefully you can explain it for me. I use row version on my objects to track concurrency issues. public class MyObject
{
public int Id { get; set; }
public string Name { get; set; }
[TimeStamp]
public byte[] RowVersion { get; set; }
} I just worked out how to register/add the services
.AddGraphQLServer()
// ... cut short for brevity
.AddType(new UuidType('D'))
.AddType<ByteArrayType>(); I can see looking at the source this should make a nice base64 string which is how it would work if I implemented a controller REST API equivalent so this is great. However, I get an error which seems to suggest its only looking at the single byte (because it says "errors": [
{
"message": "ByteArray cannot serialize the given value.",
"locations": [
{
"line": 29,
"column": 5
}
],
"path": [
"myObjects",
19,
"rowVersion",
0
],
"extensions": {
"actualValue": "0",
"actualType": "System.Byte",
"code": "EXEC_INVALID_LEAF_VALUE"
}
}, I am pulling the data from my In my code-first type I am declaring the descriptor description and nothing else: descriptor
.Field(v => v.RowVersion)
.Description("Row version used for comparing on updates or deletions."); For my GUID the format I wanted was 'D' as it helps our other applications work with the endpoint. I didn't have to add anything to the descriptor to make this work. But maybe I have to for a byte array to work? Any ideas what I am missing? thanks |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 9 replies
-
Can you create a small repro? |
Beta Was this translation helpful? Give feedback.
-
Explicitly configuring the public class MyObjectObjectType : ObjectType<MyObject>
{
protected override void Configure(IObjectTypeDescriptor<MyObject> descriptor)
{
descriptor
.Field(_ => _.RowVersion)
.Type<ByteArrayType>();
}
}
// in Startup ConfigureServices
services
.AddGraphQLServer()
.AddType<MyObjectObjectType>()
... It may be a bug on HC implicit configuration for |
Beta Was this translation helpful? Give feedback.
-
@gojanpaolo how to make it work implicity? |
Beta Was this translation helpful? Give feedback.
Explicitly configuring the
RowVersion
field to be ofType<ByteArrayType>
should resolve the error:It may be a bug on HC implicit configuration for
byte[]
whenByteArrayType
is added.