Skip to content

Commit 6f005eb

Browse files
committed
fixing more types
1 parent 5e6b51d commit 6f005eb

File tree

5 files changed

+21
-14
lines changed

5 files changed

+21
-14
lines changed

src/core/ApolloClient.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { invariant, newInvariantError } from "../utilities/globals/index.js";
22

3-
import type { ExecutionResult, DocumentNode } from "graphql";
3+
import type { DocumentNode, FormattedExecutionResult } from "graphql";
44

55
import type { FetchResult, GraphQLRequest } from "../link/core/index.js";
66
import { ApolloLink, execute } from "../link/core/index.js";
@@ -571,7 +571,9 @@ export class ApolloClient<TCacheShape> implements DataProxy {
571571
this.devToolsHookCb = cb;
572572
}
573573

574-
public __requestRaw(payload: GraphQLRequest): Observable<ExecutionResult> {
574+
public __requestRaw(
575+
payload: GraphQLRequest
576+
): Observable<FormattedExecutionResult> {
575577
return execute(this.link, payload);
576578
}
577579

src/link/core/types.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { GraphQLError, GraphQLFormattedError } from "graphql";
1+
import type { GraphQLFormattedError } from "graphql";
22
import type { DocumentNode } from "graphql";
33
import type { DefaultContext } from "../../core/index.js";
44
export type { DocumentNode };
@@ -18,7 +18,7 @@ export interface ExecutionPatchInitialResult<
1818
// if data is present, incremental is not
1919
data: TData | null | undefined;
2020
incremental?: never;
21-
errors?: ReadonlyArray<GraphQLError>;
21+
errors?: ReadonlyArray<GraphQLFormattedError>;
2222
extensions?: TExtensions;
2323
}
2424

@@ -28,7 +28,7 @@ export interface IncrementalPayload<TData, TExtensions> {
2828
data: TData | null;
2929
label?: string;
3030
path: Path;
31-
errors?: ReadonlyArray<GraphQLError>;
31+
errors?: ReadonlyArray<GraphQLFormattedError>;
3232
extensions?: TExtensions;
3333
}
3434

src/link/error/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { ExecutionResult, GraphQLFormattedError } from "graphql";
1+
import type { FormattedExecutionResult, GraphQLFormattedError } from "graphql";
22

33
import type { NetworkError } from "../../errors/index.js";
44
import { Observable } from "../../utilities/index.js";
@@ -8,7 +8,7 @@ import { ApolloLink } from "../core/index.js";
88
export interface ErrorResponse {
99
graphQLErrors?: ReadonlyArray<GraphQLFormattedError>;
1010
networkError?: NetworkError;
11-
response?: ExecutionResult;
11+
response?: FormattedExecutionResult;
1212
operation: Operation;
1313
forward: NextLink;
1414
}

src/link/persisted-queries/index.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { invariant } from "../../utilities/globals/index.js";
33
import { print } from "../../utilities/index.js";
44
import type {
55
DocumentNode,
6-
ExecutionResult,
6+
FormattedExecutionResult,
77
GraphQLError,
88
GraphQLFormattedError,
99
} from "graphql";
@@ -28,7 +28,7 @@ export const VERSION = 1;
2828
export interface ErrorResponse {
2929
graphQLErrors?: ReadonlyArray<GraphQLFormattedError>;
3030
networkError?: NetworkError;
31-
response?: ExecutionResult;
31+
response?: FormattedExecutionResult;
3232
operation: Operation;
3333
meta: ErrorMeta;
3434
}
@@ -173,7 +173,7 @@ export const createPersistedQueryLink = (
173173

174174
const { query } = operation;
175175

176-
return new Observable((observer: Observer<ExecutionResult>) => {
176+
return new Observable((observer: Observer<FormattedExecutionResult>) => {
177177
let subscription: ObservableSubscription;
178178
let retried = false;
179179
let originalFetchOptions: any;
@@ -182,7 +182,10 @@ export const createPersistedQueryLink = (
182182
{
183183
response,
184184
networkError,
185-
}: { response?: ExecutionResult; networkError?: ServerError },
185+
}: {
186+
response?: FormattedExecutionResult;
187+
networkError?: ServerError;
188+
},
186189
cb: () => void
187190
) => {
188191
if (!retried && ((response && response.errors) || networkError)) {
@@ -251,7 +254,7 @@ export const createPersistedQueryLink = (
251254
cb();
252255
};
253256
const handler = {
254-
next: (response: ExecutionResult) => {
257+
next: (response: FormattedExecutionResult) => {
255258
maybeRetry({ response }, () => observer.next!(response));
256259
},
257260
error: (networkError: ServerError) => {

src/link/subscriptions/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,13 @@
2929
// THE SOFTWARE.
3030

3131
import { print } from "../../utilities/index.js";
32-
import type { Client } from "graphql-ws";
32+
import type { Client, Sink } from "graphql-ws";
3333

3434
import type { Operation, FetchResult } from "../core/index.js";
3535
import { ApolloLink } from "../core/index.js";
3636
import { isNonNullObject, Observable } from "../../utilities/index.js";
3737
import { ApolloError } from "../../errors/index.js";
38+
import type { FormattedExecutionResult } from "graphql";
3839

3940
// https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/close_event
4041
function isLikeCloseEvent(val: unknown): val is CloseEvent {
@@ -80,7 +81,8 @@ export class GraphQLWsLink extends ApolloLink {
8081
})
8182
);
8283
},
83-
}
84+
// casting around a wrong type in graphql-ws, which incorrectly expects `Sink<ExecutionResult>`
85+
} satisfies Sink<FormattedExecutionResult> as any
8486
);
8587
});
8688
}

0 commit comments

Comments
 (0)