Skip to content

Instantly share code, notes, and snippets.

@Ahmed-ao
Created April 23, 2022 20:13
Show Gist options
  • Save Ahmed-ao/69653660b03660cc94c7830b3bfbc8f9 to your computer and use it in GitHub Desktop.
Save Ahmed-ao/69653660b03660cc94c7830b3bfbc8f9 to your computer and use it in GitHub Desktop.
apollo, react native, typescript and expo
const GET_PRODCUTS = gql`
{
products {
data {
id
attributes {
name
price
description
thumb {
data {
attributes {
url
}
}
}
}
}
}
}
`;
const { error, loading, data } = useQuery(GET_PRODCUTS);
if (loading || error) return null;
return (
<FlatList
data={data.products.data}
keyExtractor={(item) => item.id}
renderItem={({ item }) => (
<Card
containerStyle={{ height: 260 }}
source={item.attributes.thumb.data.attributes.url}
featuredTitle={item.attributes.name}
featuredSubtitle={`$${item.price}`}
onPress={() => navigation.navigate('ListingsDetails', { ...item })}
/>
)}
/>
);
"dependencies": {
"@apollo/client": "^3.5.10",
"@react-native-picker/picker": "2.2.1",
"@react-navigation/bottom-tabs": "^6.2.0",
"@react-navigation/drawer": "^6.3.1",
"@react-navigation/native": "^6.0.8",
"@react-navigation/native-stack": "^6.6.1",
"@rneui/base": "^4.0.0-rc.1",
"@rneui/themed": "^4.0.0-rc.1",
"expo": "~44.0.0",
"expo-constants": "~13.0.1",
"expo-image-picker": "~12.0.1",
"expo-location": "~14.0.1",
"expo-updates": "~0.11.6",
"formik": "^2.2.9",
"graphql": "^16.3.0",
"husky": "^7.0.4",
"jscodeshift": "0.11.0",
"react": "17.0.1",
"react-dom": "17.0.1",
"react-native": "0.64.3",
"react-native-gesture-handler": "~2.1.0",
"react-native-reanimated": "~2.3.1",
"react-native-safe-area-context": "3.3.2",
"react-native-screens": "~3.10.1",
"react-native-svg": "12.1.1",
"react-native-svg-transformer": "^1.0.0",
"react-native-vector-icons": "^9.1.0",
"react-native-web": "0.17.1",
"yup": "^0.32.11"
},
TypeError: undefined is not a function (near '...graphql.parse...')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment