Expo Go crashing with on error message using Amplify Graphql to get an item

17 Views Asked by At

When running expo go with my react native project- which i've been working on for some months now with no issues like this before, everything works as it should until I render a page that fetches some information from my DynamoDB database. Expo go crashes and there is no error message anywhere.

import { API } from "aws-amplify";
import { Alert } from "react-native";
import { getItem } from "../graphql/queries";
import { getUser } from "../graphql/queries";
import { useAuth } from "../hooks/useAuth";
export const fetchItem = async (itemId) => {
    const auth = useAuth()
    try {
    // #########################################################
    const response = await API.graphql({
        query: getItem
        variables: {
            id: itemId
        },
        authMode: "AMAZON_COGNITO_USER_POOLS",
    });
    console.log(response)
    // ######### Inversely comment above and below #############
    // const response = await API.graphql({
    //     query: getUser,
    //     variables: {
    //         id: auth.dynamoUser.id
    //     },
    //     authMode: "AMAZON_COGNITO_USER_POOLS",
    // });
    // console.log(response)
    // #########################################################
    // Note - breaks when trying to getItem but works when we use getUser.
    //        expo crashes with no error codes -_-
  } catch (err) {
    Alert.alert("Error getting item information:", err);
  }
};

Above you can see, I'm trying to fetch data for a specific item in my Items table in DynamoDB. I've narrowed the problem down to the following sectioned out code where the uncommented portion is what is causing my app to crash, but the commented portion works. I tested my GraphQL queries in Appsync and both these query functions work fine. I have another table called Events, and when I also try to getEvent, this also breaks. But again, getUser(which is also a table in DynamoDB) works fine.

Below is my versions:


 "dependencies": {
    "@aws-amplify/cli": "^12.8.2",
    "@aws-amplify/react-native": "^1.0.3",
    "@aws-amplify/rtn-web-browser": "^1.0.3",
    "@gorhom/bottom-sheet": "^4.6.0",
    "@react-native-async-storage/async-storage": "1.18.2",
    "@react-native-community/masked-view": "^0.1.11",
    "@react-native-community/netinfo": "9.3.10",
    "@react-native-community/slider": "4.4.2",
    "@react-navigation/bottom-tabs": "^6.5.11",
    "@react-navigation/material-top-tabs": "^6.6.5",
    "@react-navigation/native": "^6.1.9",
    "@react-navigation/stack": "^6.3.20",
    "aws-amplify": "5.3.12",
    "expo": "~49.0.15",
    "expo-font": "~11.4.0",
    "expo-haptics": "12.4.0",
    "expo-linear-gradient": "~12.3.0",
    "expo-modules-autolinking": "^1.5.1",
    "expo-status-bar": "~1.6.0",
    "react": "18.2.0",
    "react-native": "0.72.10",
    "react-native-gesture-handler": "~2.12.0",
    "react-native-pager-view": "6.2.0",
    "react-native-reanimated": "3.3.0",
    "react-native-safe-area-context": "4.6.3",
    "react-native-screens": "~3.22.0",
    "react-native-svg": "13.9.0",
    "react-native-tab-view": "^3.5.2"
  },
  "devDependencies": {
    "@babel/core": "^7.20.0",
    "@babel/plugin-proposal-nullish-coalescing-operator": "^7.0.0-0",
    "@babel/plugin-proposal-optional-chaining": "^7.0.0-0",
    "@babel/plugin-transform-arrow-functions": "^7.0.0-0",
    "@babel/plugin-transform-shorthand-properties": "^7.0.0-0",
    "@babel/plugin-transform-template-literals": "^7.0.0-0",
    "@babel/preset-env": "^7.1.6",
    "react-native-svg-transformer": "^1.3.0"
  },```
0

There are 0 best solutions below