Reactjs apollo客户端rest gql传递变量/todo/2

Reactjs apollo客户端rest gql传递变量/todo/2,reactjs,react-apollo,Reactjs,React Apollo,我正在尝试将react apollo client 2.64与restful后端一起使用 localhost:/api/todos返回所有项 localhost:/api/todos/1返回单个项 我无法将参数传递到路径中。。。这样解决,但我知道这不是正确的方法: //passing as a function to add parameter instead of the gql directly export const GET_TODO = (id) => gql` query {

我正在尝试将react apollo client 2.64与restful后端一起使用

localhost:/api/todos返回所有项 localhost:/api/todos/1返回单个项

我无法将参数传递到路径中。。。这样解决,但我知道这不是正确的方法:

//passing as a function to add parameter instead of the gql directly
export const GET_TODO = (id) => gql`
query {
  todo  @rest(type: "Todo", path: "todo/${id}") {
    id
    subject
    body
    status
    result
  }
}
`;

.... 
//consuming in component: 
const { loading, error, data } = useQuery(GET_TODO(3))

  • 如何正确传递参数
  • 如何控制缓存?当我从multiple部分选择一个todo时,它应该从后端更新,然后潜在的子对象应该再次使用缓存的结果
  • 提前谢谢你