Skip to content
This repository was archived by the owner on Feb 27, 2024. It is now read-only.

Commit 822c7e3

Browse files
committed
Add optional for apollo client with auth
1 parent ebb7332 commit 822c7e3

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

api/wordpress/connector.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,17 @@ let wpApolloClient
2929
* @see https://www.apollographql.com/docs/react/api/core/ApolloClient/
3030
*
3131
* @author WebDevStudios
32-
* @return {object} Apollo client instance.
32+
* @param {boolean} auth Whether to include authentication via WP application password.
33+
* @return {object} Apollo client instance.
3334
*/
34-
export function createWpApolloClient() {
35+
export function createWpApolloClient(auth = false) {
3536
return new ApolloClient({
3637
ssrMode: false,
3738
link: new HttpLink({
3839
uri: `${wpApiUrlBase}graphql`,
3940
credentials: '',
4041
headers: {
41-
authorization: `Basic ${wpAuthorization}`
42+
authorization: auth ? `Basic ${wpAuthorization}` : ''
4243
}
4344
}),
4445
cache: new InMemoryCache()

0 commit comments

Comments
 (0)