This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { ApolloClient, ApolloLink, Observable, InMemoryCache } from "@apollo/client"; | |
import { onError } from "@apollo/client/link/error"; | |
import { RetryLink } from "@apollo/client/link/retry"; | |
import { createUploadLink } from 'apollo-upload-client' | |
const request = async (operation) => { | |
const token = "yourToken"; // you can get token from persistent storage or redux store | |
console.log('REQUESTING', operation.operationName, operation.variables); | |
operation.setContext({ | |
headers: { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import client from './src/api'; | |
import { ApolloProvider } from '@apollo/client'; | |
import Home from './src/screens/Home' | |
const App= () => { | |
return ( | |
<> | |
{....} | |
<ApolloProvider client={client}> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { ApolloClient, ApolloLink, InMemoryCache } from "@apollo/client"; | |
const link = ApolloLink.from([retryLink, requestLink, error, uploadLink]); | |
const cache = new InMemoryCache(); | |
const client = new ApolloClient({ | |
link, | |
cache, | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { RetryLink } from "@apollo/client/link/retry"; | |
const retryLink = new RetryLink({ | |
delay: { | |
initial: 5000, // milliseconds to wait before attempting the first retry | |
max: 10000, // milliseconds that the link should wait for any retry. | |
}, | |
attempts: { | |
max: 10, // number of times to try a single operation before giving up | |
retryIf: (error, _operation) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { createUploadLink } from 'apollo-upload-client' | |
const uploadLink = createUploadLink({ | |
uri: "https://spacex-production.up.railway.app/", // Replace the URL with your server URL | |
fetchPolicy: 'cache-and-network', | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { onError } from "@apollo/client/link/error"; | |
const error = onError((error) => { | |
const { graphQLErrors, networkError, operation } = error; | |
if (graphQLErrors) { | |
console.log('GRAPH QL ERROR', graphQLErrors); | |
if (!graphQLErrors[0].message) { | |
console.log('Something went wrong', graphQLErrors[0].name); | |
} else { | |
console.log("Error message", graphQLErrors[0].message); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { ApolloLink, Observable } from "@apollo/client"; | |
const request = async (operation) => { | |
const token = "yourToken"; // you can get token from persistent storage or redux store | |
console.log('REQUESTING', operation.operationName, operation.variables); | |
operation.setContext({ | |
headers: { | |
authorization: `Bearer ${token}`, | |
}, | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
render() { | |
const profileImageLeft = this._getImageLeftPosition(); | |
const profileImageTop = this._getImageTopPosition(); | |
const profileImageWidth = this._getImageWidth(); | |
const profileImageHeight = this._getImageHeight(); | |
return( | |
<Animated.Image | |
style={ | |
[styles.profileImage, { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//artist profile image position from top | |
_getImageTopPosition = () => { | |
const {scrollY} = this.state; | |
return scrollY.interpolate({ | |
inputRange: [0, 140], | |
outputRange: [ThemeUtils.relativeHeight(20), Platform.OS === 'ios' ? 8 : 10], | |
extrapolate: 'clamp', | |
useNativeDriver: true | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//artist profile image position from left | |
_getImageLeftPosition = () => { | |
const {scrollY} = this.state; | |
return scrollY.interpolate({ | |
inputRange: [0, 80, 140], | |
outputRange: [ThemeUtils.relativeWidth(30), ThemeUtils.relativeWidth(38), ThemeUtils.relativeWidth(10)], | |
extrapolate: 'clamp', | |
useNativeDriver: true | |
}); |
NewerOlder