-
Notifications
You must be signed in to change notification settings - Fork 491
Closed
Description
Version: 38a077b (current master as of post date)
Details to reproduce
Type
type Mutation {
setTime(
time: Time!
): String!
}
Resolver
func (r RootResolver) SetTime(ctx context.Context, args struct {Time graphql.Time}) (string, error) {
return "success!", nil
}
Query
mutation {
setTime(
time: 1270212221,
)
}
Error
{
"errors": [
{
"message": "wrong type"
}
],
"data": {}
}
Cause
On a 64-bit machine int is an alias for int64, so the following switch-case in time.go only catches int64:
case int:
t.Time = time.Unix(int64(input), 0)
return nil
However the value passed in is type int32 in this case
the type of the variable being switched on (value) in this case is int32. So it throws "wrong type". (Not sure why it's int32, didn't do enough digging to find out.)
Fix
This is fixed by replacing that one switch case with these two:
case int32:
t.Time = time.Unix(int64(input), 0)
return nil
case int64:
t.Time = time.Unix(input, 0)
return nil
Any reason I'm not seeing for why the switch needs to catch int instead of int32 and int64? As far as I know int will only ever refer to int32 or int64.
pavelnikolov
Metadata
Metadata
Assignees
Labels
No labels