From 976c3cfa3d898a6dbff9a5ec07c65529b66560ce Mon Sep 17 00:00:00 2001 From: Mathieu Acthernoene Date: Fri, 22 Mar 2024 15:48:55 +0100 Subject: [PATCH] Re-apply prettier after rebase --- src/client.ts | 48 ++++++++++++++++++++++---------------------- src/graphql/print.ts | 2 +- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/client.ts b/src/client.ts index f0be19e..97edb47 100644 --- a/src/client.ts +++ b/src/client.ts @@ -1,3 +1,5 @@ +import { DocumentNode, GraphQLError } from "@0no-co/graphql.web"; +import { Future, Option, Result } from "@swan-io/boxed"; import { BadStatusError, EmptyResponseError, @@ -7,24 +9,22 @@ import { badStatusToError, emptyToError, } from "@swan-io/request"; -import { ClientCache } from "./cache/cache"; -import { TypedDocumentNode } from "./types"; -import { DocumentNode, GraphQLError } from "@0no-co/graphql.web"; -import { - addTypenames, - getExecutableOperationName, - inlineFragments, -} from "./graphql/ast"; -import { Future, Option, Result } from "@swan-io/boxed"; import { P, match } from "ts-pattern"; +import { ClientCache } from "./cache/cache"; +import { readOperationFromCache } from "./cache/read"; +import { writeOperationToCache } from "./cache/write"; import { ClientError, InvalidGraphQLResponseError, parseGraphQLError, } from "./errors"; -import { writeOperationToCache } from "./cache/write"; -import { readOperationFromCache } from "./cache/read"; +import { + addTypenames, + getExecutableOperationName, + inlineFragments, +} from "./graphql/ast"; import { print } from "./graphql/print"; +import { TypedDocumentNode } from "./types"; type RequestConfig = { url: string; @@ -35,7 +35,7 @@ type RequestConfig = { }; export type MakeRequest = ( - config: RequestConfig + config: RequestConfig, ) => Future< Result< unknown, @@ -56,11 +56,11 @@ const defaultParseResponse = (payload: unknown) => match(payload) .returnType>() .with({ errors: P.select(P.array()) }, (errors) => - Result.Error(errors.map(parseGraphQLError)) + Result.Error(errors.map(parseGraphQLError)), ) .with({ data: P.select(P.not(P.nullish)) }, (data) => Result.Ok(data)) .otherwise((response) => - Result.Error(new InvalidGraphQLResponseError(response)) + Result.Error(new InvalidGraphQLResponseError(response)), ); const defaultMakeRequest: MakeRequest = ({ @@ -135,7 +135,7 @@ export class Client { request( document: TypedDocumentNode, - variables: Variables + variables: Variables, ) { const transformedDocument = this.getTransformedDocument(document); const transformedDocumentsForRequest = @@ -143,7 +143,7 @@ export class Client { const operationName = getExecutableOperationName(transformedDocument).getWithDefault( - "Untitled" + "Untitled", ); const variablesAsRecord = variables as Record; @@ -162,14 +162,14 @@ export class Client { this.cache, transformedDocument, data, - variablesAsRecord + variablesAsRecord, ); }) .tap((result) => { this.cache.setOperationInCache( transformedDocument, variablesAsRecord, - result + result, ); this.subscribers.forEach((func) => { func(); @@ -179,34 +179,34 @@ export class Client { readFromCache( document: TypedDocumentNode, - variables: Variables + variables: Variables, ) { const variablesAsRecord = variables as Record; const transformedDocument = this.getTransformedDocument(document); return match( - this.cache.getOperationFromCache(transformedDocument, variablesAsRecord) + this.cache.getOperationFromCache(transformedDocument, variablesAsRecord), ) .with(Option.P.Some(Result.P.Error(P._)), (value) => value) .otherwise(() => readOperationFromCache( this.cache, transformedDocument, - variablesAsRecord - ) + variablesAsRecord, + ), ); } query( document: TypedDocumentNode, - variables: Variables + variables: Variables, ) { return this.request(document, variables); } commitMutation( document: TypedDocumentNode, - variables: Variables + variables: Variables, ) { return this.request(document, variables); } diff --git a/src/graphql/print.ts b/src/graphql/print.ts index 36c7365..e2efff5 100644 --- a/src/graphql/print.ts +++ b/src/graphql/print.ts @@ -9,7 +9,7 @@ export const printBlockString = (string: string) => { }; const hasItems = ( - array: ReadonlyArray | undefined | null + array: ReadonlyArray | undefined | null, ): array is ReadonlyArray => !!(array && array.length); const MAX_LINE_LENGTH = 80;