Skip to content

Commit 54c69e4

Browse files
committed
Add request data to lifecycle event
1 parent 268687d commit 54c69e4

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

packages/server/src/ApolloServer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1101,7 +1101,7 @@ export class ApolloServer<in out TContext extends BaseContext = BaseContext> {
11011101
await Promise.all(
11021102
this.internals.plugins.map(
11031103
async (plugin) =>
1104-
plugin.invalidRequestWasReceived?.({ error: maybeError }),
1104+
plugin.invalidRequestWasReceived?.({ request: httpGraphQLRequest, error: maybeError }),
11051105
),
11061106
);
11071107
} catch (pluginError) {

packages/server/src/externalTypes/plugins.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import type {
2323
GraphQLRequestContextWillSendResponse,
2424
GraphQLRequestContextWillSendSubsequentPayload,
2525
} from './requestPipeline.js';
26+
import type { HTTPGraphQLRequest } from './index.js';
2627

2728
export interface GraphQLServerContext {
2829
readonly logger: Logger;
@@ -76,7 +77,7 @@ export interface ApolloServerPlugin<
7677
* incorrect headers, invalid JSON body, or invalid search params for GET),
7778
* but does not include malformed GraphQL.
7879
*/
79-
invalidRequestWasReceived?({ error }: { error: Error }): Promise<void>;
80+
invalidRequestWasReceived?({ request, error }: { request: HTTPGraphQLRequest, error: Error }): Promise<void>;
8081
// Called on startup fail. This can occur if the schema fails to load or if a
8182
// `serverWillStart` or `renderLandingPage` hook throws.
8283
startupDidFail?({ error }: { error: Error }): Promise<void>;

0 commit comments

Comments
 (0)