Javascript 如何在React Native中将查询变量传递给查询?
我正在尝试从GraphCMS获取有关API的信息,但我不确定如何实现这一点 我还没有尝试过任何东西,因为我不确定如何在我的React应用程序上向查询添加变量Javascript 如何在React Native中将查询变量传递给查询?,javascript,react-native,graphql,apollo,react-apollo,Javascript,React Native,Graphql,Apollo,React Apollo,我正在尝试从GraphCMS获取有关API的信息,但我不确定如何实现这一点 我还没有尝试过任何东西,因为我不确定如何在我的React应用程序上向查询添加变量 const NewsQuery = gql' query contentView_b0488406c55f4bf5a28ceb86138c948c($first: Int, $skip: Int, $where: PostWhereInput, $orderBy: PostOrderByInput) { contentView_co
const NewsQuery = gql'
query contentView_b0488406c55f4bf5a28ceb86138c948c($first: Int, $skip: Int, $where: PostWhereInput, $orderBy: PostOrderByInput) {
contentView_content_b0488406c55f4bf5a28ceb86138c948c: postsConnection(first: $first, skip: $skip, where: $where, orderBy: $orderBy) {
edges {
node {
status
updatedAt
createdAt
id
title
slug
category
preview
body
author
date
}
}
}
}
' // (change the ' for a tilde)
这是查询变量:
{“first”:25,“skip”:0,“orderBy”:null,“where”:{“AND”:[]}}
我希望获取API上的所有数据,以便将其呈现到我的应用程序中。我正在使用阿波罗客户端 这完全取决于您在react native上使用的客户端库app@Ezekiel对不起,忘了包括在内。我正在使用Apollo客户端。
const{loading,error,data}=useQuery(NewsQuery,{variables:{“first”:25,“skip”:0,“orderBy”:null,“where:{”和“:[]}}}})
在您的函数组件中