@@ -392,17 +392,73 @@ module SchemaDefinitions =
392392 | false , _ -> getParseError destinationType s
393393 | InlineConstant value -> value.GetCoerceError destinationType
394394
395- /// Wraps a GraphQL type definition, allowing defining field/argument
396- /// to take option of provided value.
397- let Nullable ( innerDef : #TypeDef<'Val> ) : NullableDef < 'Val > = upcast { NullableDefinition.OfType = innerDef }
398-
399- /// Wraps a GraphQL type definition, allowing defining field/argument
400- /// to take voption of provided value.
401- let StructNullable ( innerDef : #TypeDef<'Val> ) : StructNullableDef < 'Val > = upcast { StructNullableDefinition.OfType = innerDef }
402-
403- /// Wraps a GraphQL type definition, allowing defining field/argument
404- /// to take collection of provided value.
405- let ListOf ( innerDef : #TypeDef<'Val> ) : ListOfDef < 'Val , 'Seq > = upcast { ListOfDefinition.OfType = innerDef }
395+ type TypeWrapperStaticDispatch =
396+
397+ static member Nullable < 'Val >( innerDef : InputOutputDef < 'Val >) : NullableDef < 'Val > =
398+ let ofType : TypeDef < 'Val > = upcast innerDef
399+ upcast { NullableDefinition.OfType = ofType }
400+
401+ static member Nullable < 'Val >( innerDef : InputDef < 'Val >) : InputDef < 'Val option > =
402+ let ofType : TypeDef < 'Val > = upcast innerDef
403+ upcast { NullableDefinition.OfType = ofType }
404+
405+ static member Nullable < 'Val >( innerDef : OutputDef < 'Val >) : OutputDef < 'Val option > =
406+ let ofType : TypeDef < 'Val > = upcast innerDef
407+ upcast { NullableDefinition.OfType = ofType }
408+
409+ static member StructNullable < 'Val >( innerDef : InputOutputDef < 'Val >) : StructNullableDef < 'Val > =
410+ let ofType : TypeDef < 'Val > = upcast innerDef
411+ upcast { StructNullableDefinition.OfType = ofType }
412+
413+ static member StructNullable < 'Val >( innerDef : InputDef < 'Val >) : InputDef < 'Val voption > =
414+ let ofType : TypeDef < 'Val > = upcast innerDef
415+ upcast { StructNullableDefinition.OfType = ofType }
416+
417+ static member StructNullable < 'Val >( innerDef : OutputDef < 'Val >) : OutputDef < 'Val voption > =
418+ let ofType : TypeDef < 'Val > = upcast innerDef
419+ upcast { StructNullableDefinition.OfType = ofType }
420+
421+ static member ListOf < 'Val , 'Seq when 'Seq :> 'Val seq >( innerDef : InputOutputDef < 'Val >) : ListOfDef < 'Val , 'Seq > =
422+ let ofType : TypeDef < 'Val > = upcast innerDef
423+ upcast { ListOfDefinition.OfType = ofType }
424+
425+ static member ListOf < 'Val , 'Seq when 'Seq :> 'Val seq >( innerDef : InputDef < 'Val >) : InputDef < 'Seq > =
426+ let ofType : TypeDef < 'Val > = upcast innerDef
427+ upcast { ListOfDefinition.OfType = ofType }
428+
429+ static member ListOf < 'Val , 'Seq when 'Seq :> 'Val seq >( innerDef : OutputDef < 'Val >) : OutputDef < 'Seq > =
430+ let ofType : TypeDef < 'Val > = upcast innerDef
431+ upcast { ListOfDefinition.OfType = ofType }
432+
433+ /// Wraps a GraphQL input or output type definition, allowing defining field/argument
434+ /// to take option of provided value while preserving input/output kind of wrapped type.
435+ /// Input wrappers produce input definitions, output wrappers produce output definitions,
436+ /// and wrappers over types implementing both kinds keep both capabilities.
437+ /// Dispatch is selected at compile time via SRTP.
438+ let inline Nullable < ^Def , ^Wrapped when ( ^Def or TypeWrapperStaticDispatch ) : ( static member Nullable : ^Def -> ^Wrapped ) >
439+ ( innerDef : ^Def )
440+ : ^Wrapped =
441+ (( ^Def or TypeWrapperStaticDispatch) : ( static member Nullable : ^Def -> ^Wrapped ) innerDef)
442+
443+ /// Wraps a GraphQL input or output type definition, allowing defining field/argument
444+ /// to take voption of provided value while preserving input/output kind of wrapped type.
445+ /// Input wrappers produce input definitions, output wrappers produce output definitions,
446+ /// and wrappers over types implementing both kinds keep both capabilities.
447+ /// Dispatch is selected at compile time via SRTP.
448+ let inline StructNullable < ^Def , ^Wrapped when ( ^Def or TypeWrapperStaticDispatch ) : ( static member StructNullable : ^Def -> ^Wrapped ) >
449+ ( innerDef : ^Def )
450+ : ^Wrapped =
451+ (( ^Def or TypeWrapperStaticDispatch) : ( static member StructNullable : ^Def -> ^Wrapped ) innerDef)
452+
453+ /// Wraps a GraphQL input or output type definition, allowing defining field/argument
454+ /// to take collection of provided value while preserving input/output kind of wrapped type.
455+ /// Input wrappers produce input definitions, output wrappers produce output definitions,
456+ /// and wrappers over types implementing both kinds keep both capabilities.
457+ /// Dispatch is selected at compile time via SRTP.
458+ let inline ListOf < ^Def , ^Wrapped when ( ^Def or TypeWrapperStaticDispatch ) : ( static member ListOf : ^Def -> ^Wrapped ) >
459+ ( innerDef : ^Def )
460+ : ^Wrapped =
461+ (( ^Def or TypeWrapperStaticDispatch) : ( static member ListOf : ^Def -> ^Wrapped ) innerDef)
406462
407463 let internal variableOrElse other ( _ : InputExecutionContextProvider ) value ( variables : IReadOnlyDictionary < string , obj >) =
408464 match value with
@@ -1415,13 +1471,14 @@ module SchemaDefinitions =
14151471 /// <param name =" defaultValue " >If defined, this value will be used when no matching input has been provided by the requester.</param >
14161472 /// <param name =" description " >Optional input description. Usefull for generating documentation.</param >
14171473 static member SkippableInput ( name : string , typedef : #InputDef<'In> , ? description : string ) : InputFieldDef =
1474+ let typedef : InputDef < 'In > = upcast typedef
14181475 upcast { InputFieldDefinition.Name = name
14191476 Description = description |> Option.map ( fun s -> s + " Skip this field if you want to avoid saving it" )
14201477 IsSkippable = true
14211478 TypeDef =
1422- match ( box typedef) with
1423- | : ? NullableDef < 'In > as n -> n
1424- | _ -> Nullable typedef
1479+ match ( box typedef) with
1480+ | : ? NullableDef < 'In > as n -> ( n :> InputDef < 'In option >)
1481+ | _ -> Nullable typedef
14251482 DefaultValue = None
14261483 ExecuteInput = Unchecked.defaultof< ExecuteInput> }
14271484
@@ -1539,4 +1596,3 @@ module SchemaDefinitions =
15391596 Description = description
15401597 FieldsFn = fun () -> fieldsFn() |> List.toArray
15411598 ResolveType = resolveType }
1542-
0 commit comments