From e979a5ad52662d197b5e8dccf98fb1b30450f838 Mon Sep 17 00:00:00 2001 From: w3bdesign <45217974+w3bdesign@users.noreply.github.com> Date: Fri, 24 Jul 2020 01:52:27 +0200 Subject: [PATCH] Add reference to Apollo Client developer extension --- .env.example | 1 + README.md | 6 +++++- utils/apollo/ApolloClient.js | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 .env.example diff --git a/.env.example b/.env.example new file mode 100644 index 000000000..7a38b565f --- /dev/null +++ b/.env.example @@ -0,0 +1 @@ +NODE_ENV="development" \ No newline at end of file diff --git a/README.md b/README.md index ce8cce5c1..5f5937d68 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,11 @@ - [wp-graphql-woocommerce](https://github.com/wp-graphql/wp-graphql-woocommerce) Adds Woocommerce functionality to a WPGraphQL schema. - [algolia-woo-indexer](https://github.com/w3bdesign/algolia-woo-indexer) Sends WooCommerce products to Algolia. -1. Make sure WooCommerce has some products already or import some sample products +2. For debugging and testing, install either https://addons.mozilla.org/en-US/firefox/addon/apollo-developer-tools/ (Firefox) or https://chrome.google.com/webstore/detail/apollo-client-developer-t/jdkknkkbebbapilgoeccciglkfbmbnfm (Chrome) depending on your browser. + +Rename .env.example to .env so the Apollo debugger will correctly load. It will not load if the NODE_ENV variable is not correctly set. + +3. Make sure WooCommerce has some products already or import some sample products The WooCommerce sample products CSV file is available at `wp-content/plugins/woocommerce/sample-data/sample_products.csv` or [Sample products](sample_products/) diff --git a/utils/apollo/ApolloClient.js b/utils/apollo/ApolloClient.js index e2a12172a..07008f763 100644 --- a/utils/apollo/ApolloClient.js +++ b/utils/apollo/ApolloClient.js @@ -23,6 +23,7 @@ import { WOO_CONFIG } from 'utils/config/nextConfig'; export const middleware = new ApolloLink((operation, forward) => { /** * If session data exist in local storage, set value as session header. + * Here we also delete the session if it is older than 24 hours */ const session = process.browser ? localStorage.getItem('woo-session') : null; const sessionAge = process.browser