GraphQL:整数是否太长? (AWS Amplify / GraphQL转换)

问题描述 投票:0回答:1

我将GraphQL Transform用作AWS Amplify的一部分。现在,我要创建以下突变。但是,to整数似乎太长。阅读文档应该可以更长一些。您知道为什么我总是收到错误:Validation error of type WrongType: argument 'input.to' with value 'IntValue{value=49160381234}' is not a valid 'Int' @ 'createNumber

mutation createNumber {
  createNumber(input: {
    username: "[email protected]"
    to: 49160381234
  }) {
    username
    to
  }
}

这里是我的架构:

type Message
  @model
  @auth(rules: [{ allow: owner }])
  @key(fields: ["to", "from"]) # `to` as primary index and `from` as sort key.
  @key(
    name: "byToByTimestamp"
    fields: ["to", "timestamp"]
    queryField: "messagesByToByTimestamp"
  ) {
  to: Int!
  from: String!
  medium: String!
  messageBody: String!
  timestamp: Int!
}

type Number
  @model
  @key(fields: ["to"]) # Each number can only exist once.
  @key(
    name: "byUserByTo"
    fields: ["username", "to"]
    queryField: "numberByUserByTo"
  ) {
  username: String!
  to: Int!
  messages: [Message] @connection(keyName: "byToByTimestamp", fields: ["to"])
}

type User @model @key(fields: ["username"]) {
  username: String!
  numbers: [Number] @connection(keyName: "byUserByTo", fields: ["username"])
}
graphql aws-amplify
1个回答
0
投票

Int标量类型表示带符号的32位数字非分数值。支持32位整数或数字类型的响应格式应使用该类型来表示此标量...如果整数内部值表示的值小于-2 ^ 31或大于或等于2 ^ 31,则字段错误应该提出。

由于Int必须为32位值,因此其值不能大于2147483647。对于可能具有大于该值的字段,规范建议:

大于32位的数字整数值应使用String或自定义的标量类型,因为并非所有平台和传输器都支持大于32位的编码整数。

© www.soinside.com 2019 - 2024. All rights reserved.