【发布时间】:2020-08-04 01:41:23
【问题描述】:
我正在尝试运行 Id 类型为标量 Int 的 graphql 查询。
仅仅写Int没用。 Number也没有工作。然后我尝试了这个:
import { Int } from "type-graphql";
interface WhereInput {
phoneNumber_contains?: String;
id?: typeof Int;
}
但这也没有用。
const where: WhereInput = {};
if (criteria == '6') {
if (searchItem) {
where.id = Number(searchItem);
loadUsers({
variables: {
where: { id: searchItem },
},
});
}
}
现在我在where.idthat 上收到一个错误
Type 'number' is not assignable to type 'GraphQLScalarType | undefined'.
searchItem 是从文本字段中读取的,默认为字符串。如何将其更改为 Int?
我的查询:
interface UserFilter {
phoneNumber_contains?: String;
id?: typeof Int;
}
export const LoadUsersQuery = gql`
query usersList($where: UserFilter) {
users(where: $where) {
...
}
}
`;
【问题讨论】:
标签: javascript reactjs typescript graphql