Skip to content

Commit 5ce6841

Browse files
committed
fix(handler): onSubscribe can return readonly GraphQLErrors
1 parent a1f25a7 commit 5ce6841

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

docs/interfaces/HandlerOptions.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,11 @@ ___
123123

124124
### onSubscribe
125125

126-
`Optional` **onSubscribe**: (`req`: [`Request`](Request.md)<`RawRequest`\>, `params`: [`RequestParams`](RequestParams.md)) => `void` \| `GraphQLError`[] \| [`Response`](../README.md#response) \| `ExecutionArgs` \| `Promise`<`void` \| `GraphQLError`[] \| [`Response`](../README.md#response) \| `ExecutionArgs`\>
126+
`Optional` **onSubscribe**: (`req`: [`Request`](Request.md)<`RawRequest`\>, `params`: [`RequestParams`](RequestParams.md)) => `void` \| readonly `GraphQLError`[] \| [`Response`](../README.md#response) \| `ExecutionArgs` \| `Promise`<`void` \| readonly `GraphQLError`[] \| [`Response`](../README.md#response) \| `ExecutionArgs`\>
127127

128128
#### Type declaration
129129

130-
▸ (`req`, `params`): `void` \| `GraphQLError`[] \| [`Response`](../README.md#response) \| `ExecutionArgs` \| `Promise`<`void` \| `GraphQLError`[] \| [`Response`](../README.md#response) \| `ExecutionArgs`\>
130+
▸ (`req`, `params`): `void` \| readonly `GraphQLError`[] \| [`Response`](../README.md#response) \| `ExecutionArgs` \| `Promise`<`void` \| readonly `GraphQLError`[] \| [`Response`](../README.md#response) \| `ExecutionArgs`\>
131131

132132
The subscribe callback executed right after processing the request
133133
before proceeding with the GraphQL operation execution.
@@ -159,7 +159,7 @@ further execution.
159159

160160
##### Returns
161161

162-
`void` \| `GraphQLError`[] \| [`Response`](../README.md#response) \| `ExecutionArgs` \| `Promise`<`void` \| `GraphQLError`[] \| [`Response`](../README.md#response) \| `ExecutionArgs`\>
162+
`void` \| readonly `GraphQLError`[] \| [`Response`](../README.md#response) \| `ExecutionArgs` \| `Promise`<`void` \| readonly `GraphQLError`[] \| [`Response`](../README.md#response) \| `ExecutionArgs`\>
163163

164164
___
165165

src/handler.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,9 @@ export interface HandlerOptions<RawRequest = unknown> {
118118
req: Request<RawRequest>,
119119
params: RequestParams,
120120
) =>
121-
| Promise<ExecutionArgs | GraphQLError[] | Response | void>
121+
| Promise<ExecutionArgs | readonly GraphQLError[] | Response | void>
122122
| ExecutionArgs
123-
| GraphQLError[]
123+
| readonly GraphQLError[]
124124
| Response
125125
| void;
126126
/**

src/utils.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export function isObject(val: unknown): val is Record<PropertyKey, unknown> {
1212
}
1313

1414
/** @private */
15-
export function areGraphQLErrors(obj: unknown): obj is GraphQLError[] {
15+
export function areGraphQLErrors(obj: unknown): obj is readonly GraphQLError[] {
1616
return (
1717
Array.isArray(obj) &&
1818
// must be at least one error

0 commit comments

Comments
 (0)