Skip to content

Commit a643cf1

Browse files
committed
Update and upgrade ApolloClient to version 3.0.2
1 parent 45317b6 commit a643cf1

File tree

10 files changed

+213
-185
lines changed

10 files changed

+213
-185
lines changed

components/Cart/AddToCartButton.component.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { useState, useContext } from 'react';
22

33
import { v4 as uuidv4 } from 'uuid';
44

5-
import { useQuery, useMutation } from '@apollo/react-hooks';
5+
import { useQuery, useMutation } from '@apollo/client';
66

77
import { AppContext } from 'utils/context/AppContext';
88
import LoadingSpinner from 'components/LoadingSpinner/LoadingSpinner.component';

components/Cart/CartPage/CartItemsContainer.component.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Link from 'next/link';
22
import { v4 } from 'uuid';
33
import { useContext, useState } from 'react';
4-
import { useQuery, useMutation } from '@apollo/react-hooks';
4+
import { useQuery, useMutation } from '@apollo/client';
55

66
import { AppContext } from 'utils/context/AppContext';
77
import {

components/Checkout/CheckoutForm.component.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useState, useContext, useEffect } from 'react';
2-
import { useQuery, useMutation } from '@apollo/react-hooks';
2+
import { useQuery, useMutation } from '@apollo/client';
33

44
import Billing from './Billing.component';
55
import OrderDetails from './OrderDetails.component';

components/Product/IndexProducts.component.jsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,14 @@ const IndexProducts = ({ products }) => {
3232
as={`/produkt/${slug}?productId=${productId}`}
3333
>
3434
<a>
35-
<img
36-
id="product-image"
37-
className="transition duration-500 ease-in-out transform cursor-pointer hover:grow hover:shadow-lg hover:scale-105"
38-
alt={name}
39-
src={image.sourceUrl}
40-
/>
35+
{image && (
36+
<img
37+
id="product-image"
38+
className="transition duration-500 ease-in-out transform cursor-pointer hover:grow hover:shadow-lg hover:scale-105"
39+
alt={name}
40+
src={image.sourceUrl}
41+
/>
42+
)}
4143
</a>
4244
</Link>
4345
<div className="flex justify-center pt-3">

package-lock.json

Lines changed: 178 additions & 150 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nextjs-woocommerce",
3-
"version": "0.9.83",
3+
"version": "0.9.9",
44
"description": "",
55
"main": "index.js",
66
"scripts": {
@@ -12,30 +12,24 @@
1212
"author": "",
1313
"license": "ISC",
1414
"dependencies": {
15-
"@apollo/react-hooks": "^3.1.5",
16-
"@types/react": "^16.9.42",
17-
"algoliasearch": "^4.3.0",
15+
"@apollo/client": "^3.0.2",
16+
"@types/react": "^16.9.43",
17+
"algoliasearch": "^4.3.1",
1818
"apollo-boost": "^0.4.9",
19-
"apollo-cache-inmemory": "^1.6.6",
20-
"apollo-client": "^2.6.10",
21-
"apollo-link": "^1.2.14",
22-
"apollo-link-error": "^1.1.13",
23-
"apollo-link-http": "^1.5.17",
2419
"graphql": "^15.3.0",
25-
"graphql-tag": "^2.10.4",
2620
"next": "^9.4.4",
2721
"nprogress": "^0.2.0",
2822
"react": "^16.13.1",
2923
"react-dom": "^16.13.1",
30-
"react-hook-form": "^6.0.3",
31-
"react-instantsearch-dom": "^6.6.0",
24+
"react-hook-form": "^6.0.8",
25+
"react-instantsearch-dom": "^6.7.0",
3226
"react-spring": "^8.0.27",
3327
"styled-components": "^5.1.1",
3428
"uuid": "^8.2.0"
3529
},
3630
"devDependencies": {
3731
"babel-plugin-styled-components": "^1.10.7",
3832
"postcss-preset-env": "^6.7.0",
39-
"tailwindcss": "^1.4.6"
33+
"tailwindcss": "^1.5.2"
4034
}
4135
}

pages/_app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ApolloProvider } from '@apollo/react-hooks';
1+
import { ApolloProvider } from '@apollo/client'
22
import { AppProvider } from 'utils/context/AppContext';
33

44
import Router from 'next/router';

utils/apollo/ApolloClient.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
import fetch from 'node-fetch';
2-
import { ApolloClient } from 'apollo-client';
3-
import { InMemoryCache } from 'apollo-cache-inmemory';
4-
import { createHttpLink } from 'apollo-link-http';
5-
import { ApolloLink } from 'apollo-link';
2+
import {
3+
ApolloClient,
4+
InMemoryCache,
5+
createHttpLink,
6+
ApolloLink,
7+
//IntrospectionFragmentMatcher,
8+
} from '@apollo/client';
69

7-
import { IntrospectionFragmentMatcher } from 'apollo-cache-inmemory';
810
import introspectionQueryResultData from './fragmentTypes';
911

1012
import { WOO_CONFIG } from 'utils/config/nextConfig';
1113

1214
// Fragment matcher.
13-
const fragmentMatcher = new IntrospectionFragmentMatcher({
15+
/*const fragmentMatcher = new IntrospectionFragmentMatcher({
1416
introspectionQueryResultData,
15-
});
17+
});*/
1618

1719
/**
1820
* Middleware operation
@@ -88,7 +90,8 @@ const client = new ApolloClient({
8890
})
8991
)
9092
),
91-
cache: new InMemoryCache({ fragmentMatcher }),
93+
//cache: new InMemoryCache({ possibleTypes: introspectionQueryResultData }),
94+
cache: new InMemoryCache(),
9295
});
9396

9497
export default client;

utils/config/nextConfig.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,22 @@
22

33
// Live details
44

5+
/*
56
export const WOO_CONFIG = {
67
GRAPHQL_URL: 'https://woocommerce.dfweb.no/graphql',
78
ALGOLIA_APP_ID: '7L9M5Y0B1K',
89
ALGOLIA_PUBLIC_API_KEY: '925cc92373120f1bf477bb8ce0e71649',
910
ALGOLIA_INDEX_NAME: 'dfweb',
1011
};
12+
*/
1113

1214
// Development details
1315

14-
/*
1516
export const WOO_CONFIG = {
1617
GRAPHQL_URL: 'http://localhost/wp/graphql',
1718
ALGOLIA_APP_ID: '7L9M5Y0B1K',
1819
ALGOLIA_PUBLIC_API_KEY: '925cc92373120f1bf477bb8ce0e71649',
1920
};
20-
*/
21+
2122

2223
export default WOO_CONFIG;

utils/functions/functions.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,12 @@ export const getUpdatedProducts = (
9696
product.productId
9797
);
9898

99-
// If product exits ( index of that product found in the array ), update the product quantity and totalPrice
99+
// If product exists ( index of that product was found in the array ), update the product quantity and totalPrice
100100
if (-1 < productExitsIndex) {
101101
let updatedProducts = existingProductsInCart;
102102
let updatedProduct = updatedProducts[productExitsIndex];
103103

104-
// If have new qty of the product available, set that else add the qtyToBeAdded
104+
// If have new quantity of the product available, set that, else add the qtyToBeAdded
105105
updatedProduct.qty = newQty
106106
? parseInt(newQty)
107107
: parseInt(updatedProduct.qty + qtyToBeAdded);

0 commit comments

Comments
 (0)