Reactjs apollo客户端rest gql传递变量/todo/2
我正在尝试将react apollo client 2.64与restful后端一起使用 localhost:/api/todos返回所有项 localhost:/api/todos/1返回单个项 我无法将参数传递到路径中。。。这样解决,但我知道这不是正确的方法: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 {
//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))