Skip to content

Plugin event callbacks should be async #4999

@jsshapiro

Description

@jsshapiro

All currently defined event callbacks for plugins are synchronous. This means, for example, that one cannot wrap operations in a transaction if the database connection is in turn async.

The fix is to add await at all of the callback invocations in processGraphQLRequest in apollo-service-core/requestPipeline.ts, which is already an async function. await has no effect if called on non-async functions, so this should be completely backwards compatible.

If there is interest in adopting this change, I'll be happy to create a mergeable repo.

In abstract, the transaction could be started in a context factory. The problem is that there's no clean way to close the transaction connection on completion in that approach.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions