Repository navigation
Commit d889e68
Use
Convert the optional-value plumbing fed by `Define`/`DefineRec` in
SchemaDefinitions.fs from `option`/`Option` to `voption`/`ValueOption`,
per the project convention of preferring `voption` to avoid an
allocation per optional value:
- All 47 `?description`, `?deprecationReason`, `?isTypeOf`,
`?interfaces`, `?args`, `?defaultValue` and `?resolveType`
parameters across `Define`/`DefineRec` are now `[<Struct>] ?...`
(`?batching` already was). `defaultArg` became `defaultValueArg`
where these parameters are unwrapped.
- The type-system records and interfaces that store these values
(`FieldDef(inition)`, `ScalarDef(inition)`, `EnumVal`/`EnumValue`,
`EnumDef(inition)`, `ObjectDef(inition)`, `InterfaceDef(inition)`,
`UnionDef(inition)`, `InputObjectDef(inition)`,
`InputFieldDef(inition)`, `InputCustomDef(inition)`,
`SubscriptionFieldDefinition`, `SubscriptionObjectDefinition`,
`DirectiveDef`) now expose `voption` instead of `option`.
- The full introspection schema (`IntrospectionDirective`,
`IntrospectionType`, `IntrospectionTypeRef`, `IntrospectionInputVal`,
`IntrospectionEnumVal`, `IntrospectionField`, `IntrospectionSchema`)
moves to `voption` for every optional field, not only
Description/DeprecationReason/DefaultValue, so the chain from
`Define.*` down to the client type provider needs no
`Option.toValueOption`/`ValueOption.ofOption`/`Option.map` adapters.
The `__type`/`__schema` introspection resolvers in Introspection.fs
switch from `Nullable` to `StructNullable` accordingly.
- Server `Execution.fs`, `Values.fs`, `Linq.fs`, `Schema.fs` and
`Planning.fs`, and Shared `Validation.fs`
(`SchemaInfo.QueryType`/`MutationType`/`SubscriptionType`,
`TryGetTypeByRef`, `TryGetOperationType`, `tryFindInArrayOption`)
follow the same members through to `voption`.
- The client type provider learns `voption`: `Client/BaseTypes.fs`
and `Client/Serialization.fs` (new `ReflectionPatterns.isValueOption`
/ `(|ValueOption|_|)` / `makeValueOption` helpers, added alongside
the existing `option`-only ones since `GraphQLResponse.Errors` and
provided-type runtime values still use `option`), and
`Client.DesignTime/ProvidedTypesHelper.fs`
(`ProvidedTypeMetadata.Description`,
`RecordPropertyMetadata.Description`/`DeprecationReason`).
- `Server.Middleware/SchemaDefinitions.fs` (`ObjectListFilterType`)
and the test helper `OptionalsNormalizationTests.ValidString.fs`
(`Define.ValidStringScalar`, which forwards `?description`) follow.
- Ran `dotnet fantomas` on every changed file; several of them had
pre-existing formatting drift from the pinned Fantomas version,
which the formatter now corrects alongside the semantic changes.
This is a source-breaking change for callers of the affected
`Define`/`DefineRec` members (`?description = someOption`-style
forwarding must now pass a `voption`) and for code that pattern-
matches `Some`/`None` on `.Description`, `.DeprecationReason`,
`.DefaultValue`, `.IsTypeOf`, `.ResolveType`, or on any field of the
`Introspection*` types (must switch to `ValueSome`/`ValueNone`).
Out of scope (left for a follow-up): `Schema`'s `?mutation`/
`?subscription`/`?config` constructor parameters, `TypeMap`'s
`?overwrite`/`?includeDefaultTypes`, `SchemaConfig.SetExecute`'s
`?overwrite`, the Middleware `Define.*Middleware` helpers,
`ObjectListFilter.Apply`, `ValidationError.AsResult`'s `?path`, and
the client's `Locations.Create`'s `?folderPath`.
Verified: `dotnet build` on both `FSharp.Data.GraphQL.slnx` and
`FSharp.Data.GraphQL.Integration.slnx` succeeds with 0 errors/warnings;
`FSharp.Data.GraphQL.Tests` (627 passed, 5 pre-existing skips) and
`FSharp.Data.GraphQL.IntegrationTests` (105 passed, exercising the
client type provider's schema deserialization and `voption`
quotation end to end) both pass.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>[<Struct>] ? optional parameters and voption in Define/DefineRec and the introspection chain1 parent e17cccc commit d889e68
17 files changed
Lines changed: 448 additions & 406 deletions
File tree
- src
- FSharp.Data.GraphQL.Client.DesignTime
- FSharp.Data.GraphQL.Client
- FSharp.Data.GraphQL.Server.AspNetCore
- FSharp.Data.GraphQL.Server.Middleware
- FSharp.Data.GraphQL.Server
- tests/FSharp.Data.GraphQL.Tests
- Variables and Inputs
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
| 38 | + | |
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| |||
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
110 | | - | |
| 110 | + | |
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
115 | | - | |
| 115 | + | |
116 | 116 | | |
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
120 | 120 | | |
121 | | - | |
122 | | - | |
| 121 | + | |
| 122 | + | |
123 | 123 | | |
124 | 124 | | |
125 | 125 | | |
| |||
154 | 154 | | |
155 | 155 | | |
156 | 156 | | |
157 | | - | |
158 | | - | |
| 157 | + | |
| 158 | + | |
159 | 159 | | |
160 | 160 | | |
161 | 161 | | |
| |||
529 | 529 | | |
530 | 530 | | |
531 | 531 | | |
532 | | - | |
| 532 | + | |
533 | 533 | | |
534 | 534 | | |
535 | 535 | | |
| |||
587 | 587 | | |
588 | 588 | | |
589 | 589 | | |
590 | | - | |
| 590 | + | |
591 | 591 | | |
592 | 592 | | |
593 | 593 | | |
594 | | - | |
| 594 | + | |
595 | 595 | | |
596 | 596 | | |
597 | 597 | | |
| |||
629 | 629 | | |
630 | 630 | | |
631 | 631 | | |
632 | | - | |
| 632 | + | |
633 | 633 | | |
634 | 634 | | |
635 | 635 | | |
| |||
646 | 646 | | |
647 | 647 | | |
648 | 648 | | |
649 | | - | |
| 649 | + | |
650 | 650 | | |
651 | 651 | | |
652 | 652 | | |
| |||
661 | 661 | | |
662 | 662 | | |
663 | 663 | | |
664 | | - | |
| 664 | + | |
665 | 665 | | |
666 | 666 | | |
667 | 667 | | |
| |||
670 | 670 | | |
671 | 671 | | |
672 | 672 | | |
673 | | - | |
| 673 | + | |
674 | 674 | | |
675 | 675 | | |
676 | 676 | | |
| |||
681 | 681 | | |
682 | 682 | | |
683 | 683 | | |
684 | | - | |
685 | | - | |
| 684 | + | |
| 685 | + | |
686 | 686 | | |
687 | 687 | | |
688 | 688 | | |
| |||
691 | 691 | | |
692 | 692 | | |
693 | 693 | | |
694 | | - | |
695 | | - | |
| 694 | + | |
| 695 | + | |
696 | 696 | | |
697 | 697 | | |
698 | 698 | | |
| |||
833 | 833 | | |
834 | 834 | | |
835 | 835 | | |
836 | | - | |
837 | | - | |
| 836 | + | |
| 837 | + | |
838 | 838 | | |
839 | 839 | | |
840 | | - | |
841 | | - | |
| 840 | + | |
| 841 | + | |
842 | 842 | | |
843 | 843 | | |
844 | | - | |
845 | | - | |
| 844 | + | |
| 845 | + | |
846 | 846 | | |
847 | 847 | | |
848 | 848 | | |
| |||
857 | 857 | | |
858 | 858 | | |
859 | 859 | | |
860 | | - | |
861 | | - | |
| 860 | + | |
| 861 | + | |
862 | 862 | | |
863 | 863 | | |
864 | 864 | | |
| |||
868 | 868 | | |
869 | 869 | | |
870 | 870 | | |
871 | | - | |
872 | | - | |
| 871 | + | |
| 872 | + | |
873 | 873 | | |
874 | 874 | | |
875 | 875 | | |
| |||
891 | 891 | | |
892 | 892 | | |
893 | 893 | | |
894 | | - | |
| 894 | + | |
895 | 895 | | |
896 | 896 | | |
897 | 897 | | |
| |||
900 | 900 | | |
901 | 901 | | |
902 | 902 | | |
903 | | - | |
904 | | - | |
| 903 | + | |
905 | 904 | | |
906 | | - | |
907 | | - | |
| 905 | + | |
| 906 | + | |
908 | 907 | | |
909 | 908 | | |
910 | 909 | | |
911 | | - | |
912 | | - | |
| 910 | + | |
913 | 911 | | |
914 | | - | |
915 | | - | |
| 912 | + | |
| 913 | + | |
916 | 914 | | |
917 | 915 | | |
918 | 916 | | |
| |||
0 commit comments