AWS Appsync-设置从列表查询返回的行的限制

时间:2019-07-19 17:50:30

标签: graphql aws-amplify aws-appsync ampl

我想增加返回的行数,使其大于默认值10。使用limit参数似乎无效。

我尝试以几种不同的方式传递限制,但是我总是只收到返回的默认10行。返回的行应与过滤条件匹配的12行。

  const filter = {
    or: [
      { firstname: { contains: searchValue } },
      { lastname: { contains: searchValue } },
      { emailaddress: { contains: searchValue } },
      { phone: { contains: searchValue } }
    ]

  };

  const limit = {limit: 50};
  // const limit = 50; // this does not work either

  const result = await API.graphql(
    graphqlOperation(listProviders, {filter}, {limit})
  );

我希望收到符合过滤条件的真实行数。仅收回10行。我在做什么错?

1 个答案:

答案 0 :(得分:1)

你很近。

const result = await API.graphql(
  graphqlOperation(listProviders, {filter}, {limit})
);

是错误的语法。 graphqlOperation仅接受两个参数:查询和一些选项。您想将两个键都放在该对象上。

const limit = 50;
const result = await API.graphql(
  graphqlOperation(listProviders, {filter, limit})
);
相关问题