GraphQL错误:Int类型的变量junctionId!用于期望bigint的位置

时间:2019-09-18 01:44:41

标签: reactjs postgresql graphql apollo-client hasura

当我尝试使用apollo客户端查询数据库时,我向我显示了这样的错误:“ GraphQL错误:Int!类型的变量junctionId用于期望bigint的位置”

我正在尝试使用hasura连接作为Postgres时间序列数据库的数据库。

export const GET_TIME = gql`
query GetTime($junctionId: Int!, $type: String!){
  timeseries_vehicles_time_points(limit: 100, where: {vehicle_type: {_eq: $type}, id: {_eq: $junctionId}},order_by: {time: asc},distinct_on: time) {
    data_t:time
    data_y:value
  }
}
`;


const car = useQuery(GET_TIME, { variables: { junctionId: `${props.junctionId}`, type: "car" } })

1 个答案:

答案 0 :(得分:0)

签出the Hasura docs on supported types可以更好地了解PostgreSQL类型。您所提供的错误说明您的变量存在问题。您需要使用bigint(或bigint!,如果它是不可为空的字段,例如您的示例)。

query GetTime($junctionId: bigint!, $type: String!){
  timeseries_vehicles_time_points(limit: 100, where: {vehicle_type: {_eq: $type}, id: {_eq: $junctionId}},order_by: {time: asc},distinct_on: time) {
    data_t:time
    data_y:value
  }
}