1
我試圖使用GraphQL
在MongoDB
中存儲UNIX時間戳,但它認爲GraphQL有處理整數的限制。請參見下面的突變:GraphQL大整數錯誤:Int不能表示非32位有符號整數值
const addUser = {
type: UserType,
description: 'Add an user',
args: {
data: {
name: 'data',
type: new GraphQLNonNull(CompanyInputType)
}
},
resolve(root, params) {
params.data.creationTimestamp = Date.now();
const model = new UserModel(params.data);
const saved = model.save();
if (!saved)
throw new Error('Error adding user');
return saved;
}
}
結果:
"errors": [
{
"message": "Int cannot represent non 32-bit signed integer value: 1499484833027",
"locations": [
{
"line": 14,
"column": 5
}
],
"path": [
"addUser",
"creationTimestamp"
]
}
I'm目前使用GraphQLInteger
對類型定義這個領域:
creationTimestamp: {
type: GraphQLInt
}
我怎樣才能解決這種情況,如果有沒有更大的GraphQLInt
可在GraphQL
?