From 2e57d1a9069c97b9a275f722c79244c78e55c30e Mon Sep 17 00:00:00 2001
From: Chuksy Olisa <chuksynaza@users.noreply.github.com>
Date: Tue, 28 Sep 2021 12:44:59 +1000
Subject: [PATCH] Bugfix/make normalize method function (#113)

Fix lint broken by 78b9f2b
---
 src/index.ts | 33 +++++++++++++++------------------
 1 file changed, 15 insertions(+), 18 deletions(-)

diff --git a/src/index.ts b/src/index.ts
index 1d3ea50..0b193a0 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -137,6 +137,20 @@ const observableWithError = (error: Error): Observable<FetchResult> =>
     observer.error(error)
   })
 
+/**
+ * Normalizes a WildcardMockedResponse removing @client directives from query
+ */
+const normalizeMockedResponse = (
+  mockedResponse: WildcardMockedResponse,
+): WildcardMockedResponse => {
+  const newMockedResponse = { ...mockedResponse }
+  const newQuery = removeClientSetsFromDocument(newMockedResponse.request.query)
+  if (newQuery) {
+    newMockedResponse.request.query = newQuery
+  }
+  return newMockedResponse
+}
+
 /**
  * Extends MockLink to provide the ability to match request queries independent
  * of their variables and have them match 1 or more responses. Also stores the
@@ -188,28 +202,11 @@ export class WildcardMockLink extends ApolloLink {
     }
 
     mockedResponses.forEach((mockedResponse) => {
-      const normalizedMockResponse =
-        this.normalizeMockedResponse(mockedResponse)
+      const normalizedMockResponse = normalizeMockedResponse(mockedResponse)
       this.addMockedResponse(normalizedMockResponse)
     })
   }
 
-  /**
-   * Normalizes a WildcardMockedResponse removing @client directives from query
-   */
-  private normalizeMockedResponse(
-    mockedResponse: WildcardMockedResponse,
-  ): WildcardMockedResponse {
-    const newMockedResponse = { ...mockedResponse }
-    const newQuery = removeClientSetsFromDocument(
-      newMockedResponse.request.query,
-    )
-    if (newQuery) {
-      newMockedResponse.request.query = newQuery
-    }
-    return newMockedResponse
-  }
-
   request(op: Operation): Observable<FetchResult> | null {
     const opDefNode = op.query.definitions.find(isOperationDefinitionNode)
     const operationType = opDefNode?.operation