我正在尝试将一组字符串从 reactjs 发送到 micronaut,以测试数据是否成功传递,我在前端有这样的东西:
const [filterName, setName] = useState(["test"]);
const age = 1;
const { data: people } = useSWR([`
query ($name:[String], $age:Int){
getName(name:$name, age:$age){ ... }`, filterName, age], (query, filterName, age) => fetcher(query, {filterName, age}))
我的 micronaut 后端看起来像这样:
@GraphQLQuery(name = "getName")
List<User> getName (@GraphQLArgument(name = "name") List<String> name,
@GraphQLArgument(name = "age") Integer age ){
System.out.println("name: " + name.toString());
System.out.println("age: " + age);
}
我可以打印年龄,但名称打印为空。难道我做错了什么?我尝试使用 ArrayList 代替 List,仍然无法正确接收名称。希望您能提供帮助。谢谢!