amplify-js: GraphQL returning Undefined
Before opening, please confirm:
- I have searched for duplicate or closed issues and discussions.
- I have read the guide for submitting bug reports.
- I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
JavaScript Framework
React Native
Amplify APIs
GraphQL API
Amplify Categories
auth, api
Environment information
# Put output below this line
System:
OS: macOS 11.3
CPU: (8) x64 Intel(R) Core(TM) i5-1038NG7 CPU @ 2.00GHz
Memory: 168.34 MB / 16.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 14.16.0 - /usr/local/bin/node
Yarn: 1.22.10 - /usr/local/bin/yarn
npm: 7.11.2 - /usr/local/bin/npm
Browsers:
Brave Browser: 90.1.23.73
Chrome: 90.0.4430.93
Safari: 14.1
npmPackages:
@aws-amplify/api: ^3.2.30 => 3.2.30
@babel/core: ^7.13.16 => 7.13.16
@babel/runtime: ^7.13.17 => 7.13.17
@react-native-async-storage/async-storage: ^1.15.4 => 1.15.4
@react-native-community/eslint-config: ^2.0.0 => 2.0.0
@react-native-community/netinfo: ^6.0.0 => 6.0.0
@types/jest: ^26.0.23 => 26.0.23
@types/react: ^17.0.4 => 17.0.4
@types/react-native: ^0.64.4 => 0.64.4
@types/react-test-renderer: ^17.0.1 => 17.0.1
HelloWorld: 0.0.1
amazon-cognito-identity-js: ^4.6.0 => 4.6.0
aws-amplify: ^3.3.27 => 3.3.27
aws-amplify-react-native: ^4.3.2 => 4.3.2
babel-jest: ^26.6.3 => 26.6.3
dateformat: ^4.5.1 => 4.5.1
eslint: ^7.25.0 => 7.25.0
hermes-inspector-msggen: 1.0.0
jest: ^26.6.3 => 26.6.3
metro-react-native-babel-preset: ^0.66.0 => 0.66.0 (0.64.0)
react: 17.0.1 => 17.0.1
react-native: 0.64.0 => 0.64.0
react-native-fast-image: ^8.3.4 => 8.3.4
react-native-flash-message: ^0.1.23 => 0.1.23
react-native-gesture-handler: ^1.10.3 => 1.10.3
react-native-image-crop-picker: ^0.36.0 => 0.36.0
react-native-indicators: ^0.17.0 => 0.17.0
react-native-maps: ^0.28.0 => 0.28.0
react-native-material-textfield: ^0.16.1 => 0.16.1
react-native-modal: ^11.10.0 => 11.10.0
react-native-modalize: ^2.0.8 => 2.0.8
react-native-phone-number-input: ^2.0.1 => 2.0.1
react-native-pose: ^0.9.1 => 0.9.1
react-native-reanimated: ^2.1.0 => 2.1.0
react-native-responsive-dimensions: ^3.1.1 => 3.1.1
react-native-safe-area-context: ^3.2.0 => 3.2.0
react-native-screens: ^3.1.1 => 3.1.1
react-native-splash-screen: ^3.2.0 => 3.2.0
react-native-storage: ^1.0.1 => 1.0.1
react-native-super-grid: ^4.1.1 => 4.1.1
react-native-vector-icons: ^8.1.0 => 8.1.0
react-navigation: ^4.4.4 => 4.4.4
react-navigation-animated-switch: ^0.6.4 => 0.6.4
react-navigation-hooks: ^1.1.0 => 1.1.0
react-navigation-stack: ^2.10.4 => 2.10.4
react-navigation-tabs: ^2.11.1 => 2.11.1
react-test-renderer: 17.0.1 => 17.0.1
rn-placeholder: ^3.0.3 => 3.0.3
typescript: ^4.2.4 => 4.2.4 (3.9.9)
npmGlobalPackages:
@aws-amplify/cli: 4.46.1
apollo-codegen: 0.20.2
expo-cli: 4.3.2
firebase-tools: 9.1.0
nodemon: 2.0.7
npm: 7.11.2
truffle: 5.2.6
yarn: 1.22.10
Describe the bug
I have reported this issue before but then the code worked so it got closed. However, now it is happening again:
I am trying to query the API with the following code, however, it is erroring with an ‘undefined’ error.
The network is empty when I query the API:

This is the code:
const users = (await API.graphql(
graphqlOperation(listUsers, {
filter: {email: {eq: email}},
}),
)) as GraphQLResult<ListUsersQuery>;
Expected behavior
I expect it to return a graphql result.
Reproduction steps
- amplify add api
- created the schema
- perform the above graphql query
- gives error as undefined
Code Snippet
// Put your code below this line.
Log output
// Put your logs below this line
LOG [DEBUG] 41:45.405 AuthClass - signIn MFA required
LOG [DEBUG] 41:45.408 AuthClass - Getting current session
LOG [DEBUG] 41:45.409 AuthClass - Failed to get user from user pool
LOG [DEBUG] 41:45.409 AuthClass - Failed to get the current user No current user
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 18 (9 by maintainers)
I would suggest using a Cognito Post Confirmation trigger to create the user in your API. https://medium.com/hackernoon/how-to-add-new-cognito-users-to-dynamodb-using-lambda-e3f55541297c
Thank you! I’ll try that now but I was trying to save the users information through the API to the database right after they sign up. How can I do it like that because it does not let the user use the api until doing the
confirmSignin?Like this?: