Skip to content

Commit

Permalink
Add request data to lifecycle event
Browse files Browse the repository at this point in the history
  • Loading branch information
Masadow committed Jun 10, 2024
1 parent 268687d commit 54c69e4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/server/src/ApolloServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1101,7 +1101,7 @@ export class ApolloServer<in out TContext extends BaseContext = BaseContext> {
await Promise.all(
this.internals.plugins.map(
async (plugin) =>
plugin.invalidRequestWasReceived?.({ error: maybeError }),
plugin.invalidRequestWasReceived?.({ request: httpGraphQLRequest, error: maybeError }),
),
);
} catch (pluginError) {
Expand Down
3 changes: 2 additions & 1 deletion packages/server/src/externalTypes/plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import type {
GraphQLRequestContextWillSendResponse,
GraphQLRequestContextWillSendSubsequentPayload,
} from './requestPipeline.js';
import type { HTTPGraphQLRequest } from './index.js';

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

0 comments on commit 54c69e4

Please sign in to comment.