amplify-js
amplify-js copied to clipboard
Inconsistency between the responses of an aws appsync query and the data available on aws dynamo.
Before opening, please confirm:
- [X] I have searched for duplicate or closed issues and discussions.
- [X] I have read the guide for submitting bug reports.
- [X] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
JavaScript Framework
Not applicable
Amplify APIs
GraphQL API
Amplify Categories
api
Environment information
# Put output below this line
System:
OS: macOS 11.6
CPU: (4) x64 Intel(R) Core(TM) i5-5257U CPU @ 2.70GHz
Memory: 224.57 MB / 8.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 14.17.6 - /usr/local/bin/node
Yarn: 1.22.11 - /usr/local/bin/yarn
npm: 6.14.15 - /usr/local/bin/npm
Browsers:
Chrome: 98.0.4758.80
Safari: 15.0
npmPackages:
@aws-amplify/datastore-storage-adapter: ^1.2.2 => 1.2.6
@azure/core-asynciterator-polyfill: ^1.0.0 => 1.0.2
@babel/core: ^7.12.9 => 7.17.2 (7.9.0)
@babel/runtime: ^7.12.9 => 7.17.2
@expo/vector-icons: ^12.0.4 => 12.0.5
@gorhom/bottom-sheet: ^4 => 4.1.5
@react-native-async-storage/async-storage: ^1.15.9 => 1.16.1
@react-native-community/clipboard: ^1.5.1 => 1.5.1
@react-native-community/datetimepicker: ^3.4.3 => 3.5.2
@react-native-community/masked-view: ^0.1.10 => 0.1.11
@react-native-community/netinfo: ^6.0.2 => 6.2.1
@react-navigation/material-bottom-tabs: ^6.0.7 => 6.1.1
@react-navigation/native: ^6.0.4 => 6.0.8
@react-navigation/native-stack: ^6.2.2 => 6.5.0
amazon-cognito-identity-js: ^5.2.0 => 5.2.6
aws-amplify: ^4.3.8 => 4.3.14
aws-amplify-react-native: ^5.0.4 => 5.0.5
axios: ^0.23.0 => 0.23.0 (0.21.4)
babel-jest: ~25.2.6 => 25.2.6 (26.6.3)
babel-plugin-transform-remove-console: ^6.9.4 => 6.9.4
core-js: ^3.12.1 => 3.21.0 (1.2.7, 2.6.12)
diff-match-patch: ^1.0.5 => 1.0.5
eslint: ^7.27.0 => 7.32.0
eslint-plugin-react: ^7.24.0 => 7.28.0
eslint-plugin-react-hooks: ^4.2.0 => 4.3.0
eslint-plugin-react-native: ^3.11.0 => 3.11.0
expo: ~41.0.0 => 41.0.1
expo-av: ^9.1.2 => 9.2.3
expo-document-picker: ~9.1.2 => 9.1.2
expo-file-system: ~11.0.2 => 11.0.2
expo-image-picker: ~10.1.3 => 10.1.4
expo-localization: ~10.1.0 => 10.1.0
expo-media-library: ^12.0.2 => 12.1.2
expo-print: ~10.1.0 => 10.1.0
expo-sharing: ^9.1.2 => 9.2.1
expo-status-bar: ~1.0.4 => 1.0.4
expo-updates: ~0.5.4 => 0.5.5
expo-web-browser: ~9.1.0 => 9.1.0
hermes-inspector-msggen: 1.0.0
jest: ~26.6.3 => 26.6.3
lottie-ios: ~3.1.8 => 3.1.9
lottie-react-native: 4.0.2 => 4.0.2
metro-react-native-babel-preset: ^0.66.2 => 0.66.2 (0.59.0)
millify: ^4.0.0 => 4.0.0
react: 17.0.2 => 17.0.2
react-dom: ^17.0.2 => 17.0.2
react-fast-compare: ^3.2.0 => 3.2.0 (2.0.4)
react-native: ~0.66.4 => 0.66.4
react-native-app-link: ^1.0.1 => 1.0.1
react-native-background-fetch: ^4.0.4 => 4.0.5
react-native-bootsplash: ^3.2.2 => 3.2.7
react-native-cn-quill: ^0.7.0 => 0.7.15
react-native-code-push: ^7.0.4 => 7.0.4
react-native-color-picker: ^0.6.0 => 0.6.0
react-native-device-info: ^8.4.7 => 8.4.9
react-native-draggable-flatlist: ^2.6.1 => 2.6.2
react-native-elements: ^3.4.2 => 3.4.2
react-native-fast-image: ^8.3.4 => 8.5.11
react-native-final-tree-view: ^3.0.0 => 3.0.0
react-native-flipper: ^0.111.0 => 0.111.0
react-native-gesture-handler: ~1.10.2 => 1.10.3
react-native-get-random-values: ^1.7.0 => 1.7.2
react-native-material-menu: ^1.2.0 => 1.2.0
react-native-modal: ^11.10.0 => 11.10.0
react-native-modal-datetime-picker: ^11.0.0 => 11.1.0
react-native-pager-view: ^5.4.4 => 5.4.9
react-native-paper: ^4.9.2 => 4.11.2
react-native-phone-number-input: ^2.1.0 => 2.1.0
react-native-popup-menu: ^0.15.10 => 0.15.12
react-native-reanimated: ^2.2.2 => 2.4.1
react-native-render-html: ^6.0.5 => 6.3.4
react-native-safe-area-context: ^3.3.2 => 3.3.2 (3.2.0)
react-native-screens: ^3.9.0 => 3.11.1
react-native-select-dropdown: ^1.4.0 => 1.8.0
react-native-share: ^5.2.2 => 5.3.0
react-native-simple-toast: ^1.1.3 => 1.1.3
react-native-skeleton-placeholder: ^3.0.4 => 3.0.4
react-native-sqlite-storage: ^6.0.1 => 6.0.1
react-native-svg: ^12.1.1-0 => 12.1.1
react-native-svg-transformer: ^0.14.3 => 0.14.3
react-native-tab-view: ^3.1.1 => 3.1.1
react-native-table-component: ^1.2.1 => 1.2.2
react-native-tags: ^2.2.0 => 2.2.1
react-native-unimodules: ~0.13.3 => 0.13.3
react-native-url-polyfill: ^1.3.0 => 1.3.0
react-native-vector-icons: ^8.1.0 => 8.1.0
react-native-web: ~0.13.12 => 0.13.18
react-native-webview: ^11.6.5 => 11.17.2
react-redux: ^7.2.5 => 7.2.6
react-test-renderer: ~17.0.2 => 17.0.2
recyclerlistview: ^3.0.5 => 3.0.5
redux: ^4.1.1 => 4.1.2
redux-devtools-extension: ^2.13.9 => 2.13.9
redux-flipper: ^2.0.1 => 2.0.1
redux-persist: ^6.0.0 => 6.0.0
redux-persist/integration/react: undefined ()
redux-thunk: ^2.3.0 => 2.4.1
reselect: ^4.0.0 => 4.1.5 (3.0.1)
rn-range-slider: ^2.1.1 => 2.1.1
shortid: ^2.2.16 => 2.2.16
uuid: ^8.3.2 => 8.3.2 (3.4.0, 3.3.2, 7.0.2, 7.0.3)
victory-native: ^35.3.2 => 35.5.5
xmldom: ^0.5.0 => 0.5.0
npmGlobalPackages:
@aws-amplify/cli: 7.6.19
appcenter-cli: 2.10.6
expo-cli: 4.12.0
npm: 6.14.15
yarn: 1.22.11
Describe the bug
When we use the appsync service from the interface provided by AWS to make graphql queries of the data available in our aws dynamoDB database, the responses to these queries are inconsistent (mostly return nothing). However, these exist in our database. We use our mobile app made with react-native and amplify datastore for operations.
Expected behavior
We expect correct responses from requests made with appsync with the data available in dynamoDB.
Reproduction steps
- make amplify init in react native project
- add amplify categories(auth, api, storage, ...)
- make datastore save operation on model type.
- visit the dynamoDB to view data.
- make query on appsync to view data.
- error:
data for some reason is not available.
Code Snippet
// Put your code below this line.
type Article
@model(subscriptions: { onDelete: null })
@auth(
rules: [
{
allow: owner
ownerField: "belongTo"
identityClaim: "custom:managerName"
}
{ allow: private, provider: iam, operations: [read, update] }
{ allow: public, provider: iam, operations: [read] }
]
) {
id: ID!
name: String
priceOut: Float
priceIn: Float
currentQty: Float
...
parentCloneID: ID
isOnline: Boolean
articleGroupID: ID
rootPath: [String]
...
storeID: ID
belongTo: String!
}
const data = {/* some data */}
await DataStore.save(new Article(data));
This is a query from dynamo console.
This is same query but in appsync console.
You can notice the responses are different.
Log output
// Put your logs below this line
aws-exports.js
No response
Manual configuration
No response
Additional configuration
No response
Mobile Device
No response
Mobile Operating System
No response
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
No response
Hello,
Thanks for raising this issue. I was able to consistently reproduce this issue following the reproduction steps provided
Payload:
Response:
I was able to successfully create App sync article that persisted to DynamoDB with same Cognito user. Marking this as a bug for team to investigate further.
Hi @frankarnaud 👋 could you try following this documentation to allow your IAM user to access the GraphQL API in the AppSync console? https://docs.amplify.aws/cli/graphql/authorization-rules/#use-iam-authorization-within-the-appsync-console
Also, please try changing the auth mode in the console to Cognito User Pools and try querying again.
Hi @frankarnaud 👋 could you try following this documentation to allow your IAM user to access the GraphQL API in the AppSync console? https://docs.amplify.aws/cli/graphql/authorization-rules/#use-iam-authorization-within-the-appsync-console
Also, please try changing the auth mode in the console to Cognito User Pools and try querying again.
Hi @chrisbonifacio, thank you for paying attention to my concern. However, I don't have a permission problem. I will apply the procedure to see if it solves the problem even if I am not too hopeful. regards.
@frankarnaud yeah, you're correct. After digging into this further last week, you would've received an unauthorized error response from AppSync if your IAM role/user didn't have access in the console.
So the issue I'm having with my reproduction is that I am getting back the expected results from a filter both in DynamoDB and in the AppSync console, unlike the description of this issue.
DynamoDB Scan and Filter
AppSync Console Query (IAM)
Can you share the cli.json
file in your amplify folder as well as the request and response resolvers for listArticles
in your amplify/api/build/resolvers
folder?
Can you share the
cli.json
file in your amplify folder as well as the request and response resolvers forlistArticles
in youramplify/api/build/resolvers
folder?
Hi,
I can't find the resolvers in the mentioned path as shown with the capture
Looks like you're on an older version of the amplify CLI. Would you be able to upgrade to the latest version, make a small change to the schema, and then run amplify build
? You can also run amplify push
if it compiles successfully.
I created my api using the latest CLI version and wasn't able to reproduce the issue on the latest version.
After redeploying the backend, attempt the query again and let me know if the result of the query is any different.
Hello, sorry the program has been very busy these last few days. I will try to do what you say. Some concerns however because we use datastore on our front-end and had already had problems when the schema is changed
@frankarnaud no worries! The change to the schema could be as simple as a comment and the Amplify CLI will recognize it as having been updated so you can run amplify push
again to rebuild and deploy the backend with the latest cli version.
Hi, here is what you are probably asking
,
Seems to longer be an issue in the latest CLI. Please comment if you are still experiencing the issue.