Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/entity-framework/4.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
Reactjs 将多个变量传递到Apollo查询组件 const GET\u DOG\u PHOTO=gql` 查询狗($bride:String!){ 狗(品种:$品种){ 身份证件 显示图像 } } `; const DogPhoto=({breed})=>( {({加载,错误,数据})=>{ if(加载)返回null; if(error)返回`error!:${error}`; 返回( ); }} );_Reactjs_Apollo_React Apollo - Fatal编程技术网

Reactjs 将多个变量传递到Apollo查询组件 const GET\u DOG\u PHOTO=gql` 查询狗($bride:String!){ 狗(品种:$品种){ 身份证件 显示图像 } } `; const DogPhoto=({breed})=>( {({加载,错误,数据})=>{ if(加载)返回null; if(error)返回`error!:${error}`; 返回( ); }} );

Reactjs 将多个变量传递到Apollo查询组件 const GET\u DOG\u PHOTO=gql` 查询狗($bride:String!){ 狗(品种:$品种){ 身份证件 显示图像 } } `; const DogPhoto=({breed})=>( {({加载,错误,数据})=>{ if(加载)返回null; if(error)返回`error!:${error}`; 返回( ); }} );,reactjs,apollo,react-apollo,Reactjs,Apollo,React Apollo,我正在查看文档,我可以看到他们在查询组件的variables属性中传递了一个名为bride的props。如果查询包含两个参数,如何传入两个参数?您正在使用。这两种语法是等价的 const GET_DOG_PHOTO = gql` query Dog($breed: String!) { dog(breed: $breed) { id displayImage } } `; const DogPhoto = ({ breed }) => (

我正在查看文档,我可以看到他们在查询组件的variables属性中传递了一个名为bride的props。如果查询包含两个参数,如何传入两个参数?

您正在使用。这两种语法是等价的

const GET_DOG_PHOTO = gql`
  query Dog($breed: String!) {
    dog(breed: $breed) {
      id
      displayImage
    }
  }
`;

const DogPhoto = ({ breed }) => (
  <Query query={GET_DOG_PHOTO} variables={{ breed }}>
    {({ loading, error, data }) => {
      if (loading) return null;
      if (error) return `Error!: ${error}`;

      return (
        <img src={data.dog.displayImage} style={{ height: 100, width: 100 }} />
      );
    }}
  </Query>
);
查询组件将如下所示

const GET_DOG_PHOTO = gql`
  query Dog($breed: String!, $size: Int!) {
    dog(breed: $breed, size: $size) {
      id
      displayImage
    }
  }
`;
function DogPhoto({breed,size})=>
返回(
{({加载,错误,数据})=>{
if(加载)返回null;
if(error)返回`error!:${error}`;
返回(
);
}}
)
};
您正在使用的。这两种语法是等价的

const GET_DOG_PHOTO = gql`
  query Dog($breed: String!) {
    dog(breed: $breed) {
      id
      displayImage
    }
  }
`;

const DogPhoto = ({ breed }) => (
  <Query query={GET_DOG_PHOTO} variables={{ breed }}>
    {({ loading, error, data }) => {
      if (loading) return null;
      if (error) return `Error!: ${error}`;

      return (
        <img src={data.dog.displayImage} style={{ height: 100, width: 100 }} />
      );
    }}
  </Query>
);
查询组件将如下所示

const GET_DOG_PHOTO = gql`
  query Dog($breed: String!, $size: Int!) {
    dog(breed: $breed, size: $size) {
      id
      displayImage
    }
  }
`;
function DogPhoto({breed,size})=>
返回(
{({加载,错误,数据})=>{
if(加载)返回null;
if(error)返回`error!:${error}`;
返回(
);
}}
)
};

{{breed}}
只是一种对象声明语法。。。那么简单的
{{breed,sselse}}
{{breed}}
就是一个对象声明语法。。。然后简单地
{breed,sthElse}}
我正在尝试类似于``const GET_DOG_PHOTO=gql`query DOG($order:String!){DOG(order_by:{size:$order}){id displayImage}的东西;但它不起作用…我想通过值传递order作为参数,看起来你所做的是正确的。什么工作不正常?错误:GraphQL错误:在QueryManager的bundle.esm.js:1488 at Array.forEach()处的new ApolloError(bundle.esm.js:60)处未定义。(bundle.esm.js:1486)在Object.next(tslib.es6.js:78)的步骤(tslib.es6.js:97)在tslib.es6.js:71在Object.next(bundle.esm.js:1464)的新承诺()在u waiter(tslib.es6.js:67)在Object.next(bundle.esm.js:1464)中传递“asc”或“desc”作为字符串有任何问题。有一次我在说一些与“enum”相关的东西时出错了。我忘了我做了什么改变。我正在尝试类似于“const GET_DOG_PHOTO=gql”的查询狗($order:String!){DOG(order_by:{size:$order}){id displayImage};但它不起作用…我想通过值传递order作为参数,看起来你所做的是正确的。什么工作不正常?错误:GraphQL错误:在QueryManager的bundle.esm.js:1488 at Array.forEach()处的new ApolloError(bundle.esm.js:60)处未定义。(bundle.esm.js:1486)在Object.next(tslib.es6.js:78)的步骤(tslib.es6.js:97)在tslib.es6.js:71在Object.next(bundle.esm.js:1464)的新承诺()在u waiter(tslib.es6.js:67)在Object.next(bundle.esm.js:1464)中传递“asc”或“desc”作为字符串有任何问题。有一次我在说一些与“enum”相关的东西时出错了。我忘了我做了什么改变