Skip to content

refactor(middleware): drop *resolvable.Schema from Exec signature#12

Merged
michieldewilde merged 1 commit intomasterfrom
middleware-decouple-from-internal-schema
May 7, 2026
Merged

refactor(middleware): drop *resolvable.Schema from Exec signature#12
michieldewilde merged 1 commit intomasterfrom
middleware-decouple-from-internal-schema

Conversation

@michieldewilde
Copy link
Copy Markdown

@michieldewilde michieldewilde commented May 6, 2026

Description

The Exec middleware type previously included a *resolvable.Schema parameter sourced from internal/exec/resolvable. Because Go forbids importing internal/ packages from outside the module, consumers of graphql-go could only define middleware in code that lives inside this module - the type they would have to reference wasn't reachable from anywhere else.

The Exec middleware type accepted a *resolvable.Schema parameter that
came from internal/exec/resolvable. Because Go forbids importing
internal/ packages from outside the module, anyone consuming
graphql-go could only define middleware that compiled inside this
module - the type they would have to reference wasn't visible to them.

The parameter wasn't useful externally either: the schema is fixed
for the lifetime of Schema.Exec, so middlewares can't substitute it.
Schema.Exec now closes over s.res when wrapping middleware, and the
Exec type loses the parameter. This lets downstream code (Spacelift
backend in particular) define its own middleware in any package.

Built-in middlewares (ParseErrorsMiddleware, InspectInputMiddleware)
and the existing TestMiddlewares_In_Exec are updated to match.
@michieldewilde michieldewilde requested a review from a team May 6, 2026 14:28
@michieldewilde michieldewilde marked this pull request as ready for review May 7, 2026 07:18
@michieldewilde michieldewilde merged commit 5c90c28 into master May 7, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants