I'm trying to pass an int value as seconds scalar to my graphql-backend. The frontend uses vue-apollo and the backend is written in dotnet core using graphql-dotnet.
When I call the mutation via playground, everything works fine. Neither does my vue app throw any error/exception nor works the mutation. The mutation is called in the backend, but the value for s
is null (and so 00:00:00 as it is a TimeSpan). The backend is written in dotnet core 3.1 but as I said the convertion from a given number to TimeSpanSecondsGraphType works via playground.
frontend code
My mutation looks like
updateS(
sId: ID = null
s: s = null
): SType
My input type s looks like
type s {
s: Seconds = null
}
And my SType looks like
type SType {
s: Seconds
}
Working example call (via playground)
mutation {
updateS(s: "08d924e8-69fb-425c-8130-de7342a2ca2a", s: {
s: 3600
}) {
s
}
}
This is the payload from chrome when I call the mutation in my vue-app (not working):
{"operationName":"updateS","variables":{"sId":"08d924e8-69fb-425c-8130-de7342a2ca2a","s":{"s":3600}},"query":"mutation updateS($sId: ID!, $s: s!) {\n updateS(sId: $sId, s: $s) {\n s\n__typename\n }\n}\n"}
Edit - Added backend code
dotnet core mutation and models
This is my mutation in the backend:
Field<SType>(
"updateS",
arguments: new QueryArguments(
new QueryArgument<IdGraphType> { Name = "sId" },
new QueryArgument<SInputType> { Name = "s" }
),
resolve: context =>
{
var sId = context.GetArgument<Guid>("sId");
var s = context.GetArgument<S>("s"); // s.S is always {00:00:00} when called from vue app.
return repo.UpdateS(sId, s);
});
My SInputType
:
public class SInputType : InputObjectGraphType
{
public SInputType()
{
Name = "s";
Field<TimeSpanSecondsGraphType>("s");
}
}
And my S.cs
:
public class S
{
public Guid Id { get; set; }
public TimeSpan S { get; set; }
}
Any suggestion?