Skip to content

Use [<Struct>] ? optional parameters and voption in executor middlewares and Schema - #617

Merged
xperiandri merged 1 commit into
devfrom
struct-optional-args-executor-middleware
Oct 1, 2026
Merged

xperiandri merged 1 commit into
devfrom
struct-optional-args-executor-middleware

Conversation

@xperiandri

Copy link
Copy Markdown
Collaborator

Continues #601 and #604: the remaining reference optional parameters and option values around Executor now use [<Struct>] ? and voption.

Changes

  • IExecutorMiddleware: CompileSchema, PostCompileSchema, PlanOperation and ExecuteOperationAsync return voption instead of option.
  • ExecutorMiddleware and Define.ExecutorMiddleware take [<Struct>] ?compile, ?postCompile, ?plan, ?execute.
  • Define.QueryWeightMiddleware, Define.ObjectListFilterMiddleware and Define.LiveQueryMiddleware take [<Struct>] ? arguments.
  • Schema takes [<Struct>] ?config.
  • The README middleware sample reflects the new signatures. It also adds the missing postCompile and uses named arguments, because the old positional call passed the planning function as postCompile.

Breaking changes

Custom IExecutorMiddleware implementations must return ValueSome/ValueNone instead of Some/None. Callers passing ?config = someOption, ?reportToMetadata = someOption or ?identityName = someOption must pass a voption. Calls that pass plain values do not change.

Verification

  • dotnet build FSharp.Data.GraphQL.slnx: 0 warnings, 0 errors
  • FSharp.Data.GraphQL.Tests: 764 passed, 5 skipped, 0 failed
  • dotnet build FSharp.Data.GraphQL.Integration.slnx: succeeded

🤖 Generated with Claude Code

…dlewares and `Schema`

* `IExecutorMiddleware` members return `voption` instead of `option`
* `ExecutorMiddleware` and `Define.ExecutorMiddleware` take `[<Struct>] ?` sub-middlewares
* `Define.QueryWeightMiddleware`, `Define.ObjectListFilterMiddleware` and `Define.LiveQueryMiddleware` take `[<Struct>] ?` arguments
* `Schema` takes `[<Struct>] ?config`
* README middleware sample updated, including the missing `postCompile`

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings September 27, 2026 00:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Final review comments identify documentation and API-signature corrections that should be addressed before approval.

Review effort: Lite
Findings: 1 Low severity

Open (1)
What changed in this PR

Updates executor middleware and Schema optional parameters to use struct options (voption), including implementations, tests, and documentation.

Changes:

  • Migrates middleware values from option to voption.
  • Applies [<Struct>] ? parameters across middleware and schema APIs.
  • Updates tests and README examples.
File Summary Final review notes
tests/​FSharp.Data.GraphQL.Tests/​ExecutorMiddlewareTests.fs Updates middleware tests for voption. —
src/​FSharp.Data.GraphQL.Server/​Schema.fs Converts schema configuration to a struct optional parameter. —
src/​FSharp.Data.GraphQL.Server/​Executor.fs Updates middleware APIs and execution handling. Nit (1 vote): update documentation from “one to three” sub-middlewares to four.
src/​FSharp.Data.GraphQL.Server/​DefineExtensions.fs Updates executor middleware factory parameters. —
src/​FSharp.Data.GraphQL.Server.Middleware/​MiddlewareDefinitions.fs Uses ValueSome/ValueNone. —
src/​FSharp.Data.GraphQL.Server.Middleware/​DefineExtensions.fs Updates built-in middleware optional parameters. —
README.md Documents the revised middleware API. Nit (3 votes): declare SchemaPostCompileMiddleware. Nit (1 vote): correct the interface block’s missing InputExecutionContextProvider and GQLResponse type. Nit (1 vote): correct the OperationExecutionMiddleware alias to use InputExecutionContextProvider and AsyncVal<GQLExecutionResult>.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread README.md
@github-actions

github-actions Bot commented Sep 27, 2026 •

Copy link
Copy Markdown

Test Results

    9 files      9 suites   15m 2s ⏱️
  877 tests   872 ✅  5 💤 0 ❌
2 631 runs  2 616 ✅ 15 💤 0 ❌

Results for commit 6d8e2a8.

♻️ This comment has been updated with latest results.

@xperiandri
xperiandri force-pushed the struct-optional-args-executor-middleware branch from 9a6b30a to 6d8e2a8 Compare October 1, 2026 21:27
@xperiandri
xperiandri merged commit c390637 into dev Oct 1, 2026
5 checks passed
@xperiandri
xperiandri deleted the struct-optional-args-executor-middleware branch October 1, 2026 21:37
xperiandri added a commit that referenced this pull request Oct 2, 2026
Since the `Executor` members take `[<Struct>] ?` optional parameters (#617),
the solution does not compile with SDK `10.0.303`: its F# compiler accepts
neither an `option` nor a `voption` after `?name =` for a struct optional
parameter, while SDK `10.0.401` takes the `voption`. FSharp.Core moves along
to `10.1.401`, the version SDK `10.0.401` ships.

The F# compiler of `10.0.4xx` miscompiles resumable state machines in Debug
(dotnet/fsharp#20466, fix backported in dotnet/fsharp#20692); the tests already
avoid `taskSeq` blocks that suspend, and CI builds Release.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
xperiandri added a commit that referenced this pull request Oct 2, 2026
Since the `Executor` members take `[<Struct>] ?` optional parameters (#617),
the solution does not compile with SDK `10.0.303`: its F# compiler accepts
neither an `option` nor a `voption` after `?name =` for a struct optional
parameter, while SDK `10.0.401` takes the `voption`. FSharp.Core moves along
to `10.1.401`, the version SDK `10.0.401` ships.

The F# compiler of `10.0.4xx` miscompiles resumable state machines in Debug
(dotnet/fsharp#20466, fix backported in dotnet/fsharp#20692); the tests already
avoid `taskSeq` blocks that suspend, and CI builds Release.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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