0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

amplify graphql nextTokenを利用してデータを取得しようとするとエラーになる

Posted at

はじめに

amplify graphqlにて、nextTokenを利用してdynamoDBから次のデータを取得しようとしたらエラーになって取得できなかった

スキーマ定義


export const mainList = /* GraphQL */ `
  query MainList(
    $user_name: String
    $createdAt: ModelStringKeyConditionInput
    $sortDirection: ModelSortDirection
    $filter: ModelOcrImageFilterInput
    $limit: Int
    $nextToken: String
  ) {
    mainList(
      user_name: $user_name
      createdAt: $createdAt
      sortDirection: $sortDirection
      filter: $filter
      limit: $limit
      nextToken: $nextToken
    ) {
      items {
        id
        user_name
        createdAt
        owner
      }
      nextToken
    }
  }
`;

エラーメッセージ


Object {
  "data": Object {
    "mainList": null,
  },
  "errors": Array [
    Object {
      "data": null,
      "errorInfo": null,
      "errorType": "DynamoDB:UserIllegalArgumentException",
      "locations": Array [
        Object {
          "column": 3,
          "line": 2,
          "sourceName": null,
        },
      ],
      "message": "com.amazonaws.deepdish.common.pagination.InvalidPaginationTokenException: Invalid pagination token given.",
      "path": Array [
        "mainList",
      ],
    },
  ],
}

結果

amplify/cliのバージョンが低いことが原因でした。


$ npm ls -g --depth=0
/Users/xxxxxxxx/.nvm/versions/node/v10.14.2/lib
├── @aws-amplify/cli@4.13.3
├── expo-cli@3.13.1
└── npm@6.4.1

github issue にも載っていた。
https://github.com/aws-amplify/amplify-cli/issues/3411

amplify/cli のバージョンを4.13.4以上に上げて、再度、amplify pushすることで、無事取得することができました。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?