Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在React Native中将查询变量传递给查询?_Javascript_React Native_Graphql_Apollo_React Apollo - Fatal编程技术网

Javascript 如何在React Native中将查询变量传递给查询?

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

我正在尝试从GraphCMS获取有关API的信息,但我不确定如何实现这一点

我还没有尝试过任何东西,因为我不确定如何在我的React应用程序上向查询添加变量

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:{”和“:[]}}}})
在您的函数组件中