Skip to content

Instantly share code, notes, and snippets.

View rutvikbhatt9's full-sized avatar
🎯
Focusing on new learning

Rutvik Bhatt rutvikbhatt9

🎯
Focusing on new learning
View GitHub Profile
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: {
import client from './src/api';
import { ApolloProvider } from '@apollo/client';
import Home from './src/screens/Home'
const App= () => {
return (
<>
{....}
<ApolloProvider client={client}>
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,
});
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);
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}`,
},
});
@rutvikbhatt9
rutvikbhatt9 / ArtistScreenAnimatedImage.js
Created May 28, 2019 05:02
Setting value of Intepolate to Animated.Image
render() {
const profileImageLeft = this._getImageLeftPosition();
const profileImageTop = this._getImageTopPosition();
const profileImageWidth = this._getImageWidth();
const profileImageHeight = this._getImageHeight();
return(
<Animated.Image
style={
[styles.profileImage, {
@rutvikbhatt9
rutvikbhatt9 / ArtistScreenImage.js
Last active May 28, 2019 05:00
Get Interpolation value for artist profile image top, height and width
//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
});
@rutvikbhatt9
rutvikbhatt9 / ArtistScreenPositionLeft.js
Created May 28, 2019 04:42
Get Interpolation value for artist profile image left
//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
});