diff --git a/src/FSharp.Data.GraphQL.Client.DesignTime/ProvidedTypesHelper.fs b/src/FSharp.Data.GraphQL.Client.DesignTime/ProvidedTypesHelper.fs index fe95c5761..d4fc02442 100644 --- a/src/FSharp.Data.GraphQL.Client.DesignTime/ProvidedTypesHelper.fs +++ b/src/FSharp.Data.GraphQL.Client.DesignTime/ProvidedTypesHelper.fs @@ -35,7 +35,7 @@ module internal QuotationHelpers = let exprs = coerceValues (fun _ -> typ) instance Expr.NewArray(typ, exprs) let tupleExpr (tupleType : Type) (v : obj) = - let typ = FSharpType.GetTupleElements tupleType |> Array.mapi (fun i t -> i, t) |> Map.ofArray + let typ = FSharpType.GetTupleElements tupleType |> Seq.mapi (fun i t -> i, t) |> Map.ofSeq let fieldTypeLookup i = typ.[i] let fields = FSharpValue.GetTupleFields v let exprs = coerceValues fieldTypeLookup fields @@ -107,19 +107,19 @@ module internal ProvidedEnum = type internal ProvidedTypeMetadata = { Name : string - Description : string option } + Description : string voption } module internal ProvidedInterface = let makeProvidedType(metadata : ProvidedTypeMetadata) = let tdef = ProvidedTypeDefinition("I" + metadata.Name.FirstCharUpper(), None, nonNullable = true, isInterface = true) - metadata.Description |> Option.iter tdef.AddXmlDoc + metadata.Description |> ValueOption.iter tdef.AddXmlDoc tdef type internal RecordPropertyMetadata = { Name : string Alias : string voption - Description : string option - DeprecationReason : string option + Description : string voption + DeprecationReason : string voption Type : Type } member x.AliasOrName = match x.Alias with @@ -154,8 +154,8 @@ module internal ProvidedRecord = | Some prop -> prop.Value | None -> failwith $"""Expected to find property "%s{pname}", but the property was not found.""" @@> let pdef = ProvidedProperty(pname, metadata.Type, getterCode) - metadata.Description |> Option.iter pdef.AddXmlDoc - metadata.DeprecationReason |> Option.iter pdef.AddObsoleteAttribute + metadata.Description |> ValueOption.iter pdef.AddXmlDoc + metadata.DeprecationReason |> ValueOption.iter pdef.AddObsoleteAttribute pdef)) let addConstructorDelayed (propertiesGetter : unit -> (string * string voption * Type) list) = tdef.AddMembersDelayed(fun _ -> @@ -529,7 +529,7 @@ module internal Provider = else let getIntrospectionFields typeName = match schemaTypes.TryGetValue typeName with - | true, schematype -> schematype.Fields |> Option.defaultValue [||] + | true, schematype -> schematype.Fields |> ValueOption.defaultValue [||] | false, _ -> failwith $"""Could not find a schema type based on a type reference. The reference is to a "%s{typeName}" type, but that type was not found in the schema types.""" let getPropertyMetadata typeName (info : AstFieldInfo) : RecordPropertyMetadata = let ifield = @@ -587,11 +587,11 @@ module internal Provider = let schemaTypes = TypeMapping.getSchemaTypes schema let getSchemaType (tref : IntrospectionTypeRef) = match tref.Name with - | Some name -> + | ValueSome name -> match schemaTypes.TryFind(name) with | Some itype -> itype | None -> failwithf "Type \"%s\" was not found on the schema custom types." name - | None -> failwith "Expected schema type to have a name, but it does not have one." + | ValueNone -> failwith "Expected schema type to have a name, but it does not have one." let typeModifier (modifier : Type -> Type) (metadata : RecordPropertyMetadata) = { metadata with Type = modifier metadata.Type } let makeOption = typeModifier TypeMapping.makeOption let makeArrayOption = typeModifier (TypeMapping.makeArray >> TypeMapping.makeOption) @@ -629,7 +629,7 @@ module internal Provider = { Name = field.Name Alias = ValueNone Description = field.Description - DeprecationReason = None + DeprecationReason = ValueNone Type = providedType } |> makeOption | _ when uploadInputTypeName.IsSome && field.Type.Name.IsSome && uploadInputTypeName.Value = field.Type.Name.Value && field.Type.Kind <> TypeKind.INPUT_OBJECT -> @@ -646,7 +646,7 @@ module internal Provider = { Name = field.Name Alias = ValueNone Description = field.Description - DeprecationReason = None + DeprecationReason = ValueNone Type = providedType } |> makeOption | _ -> failwith "Could not find a schema type based on a type reference. The reference has an invalid or unsupported combination of Name, Kind and OfType fields." @@ -661,7 +661,7 @@ module internal Provider = providedTypes.Value <- providedTypes.Value.Add(itype.Name, tdef) let properties = itype.Fields - |> Option.defaultValue [||] + |> ValueOption.defaultValue [||] |> Seq.map resolveFieldMetadata |> Seq.toList upcast ProvidedRecord.makeProvidedType(tdef, properties, explicitOptionalParameters) @@ -670,7 +670,7 @@ module internal Provider = providedTypes.Value <- providedTypes.Value.Add(itype.Name, tdef) let properties = itype.InputFields - |> Option.defaultValue [||] + |> ValueOption.defaultValue [||] |> Seq.map resolveInputFieldMetadata |> Seq.toList upcast ProvidedRecord.makeProvidedType(tdef, properties, explicitOptionalParameters) @@ -681,8 +681,8 @@ module internal Provider = | TypeKind.ENUM -> let items = match itype.EnumValues with - | Some values -> values |> Array.map (fun value -> value.Name) - | None -> [||] + | ValueSome values -> values |> Array.map (fun value -> value.Name) + | ValueNone -> [||] let tdef = ProvidedEnum.makeProvidedType(itype.Name, items) providedTypes.Value <- providedTypes.Value.Add(itype.Name, tdef) tdef @@ -691,8 +691,8 @@ module internal Provider = schemaTypes |> Map.iter (fun _ itype -> if not (List.contains itype.Kind ignoredKinds) then resolveProvidedType itype |> ignore) let possibleTypes (itype : IntrospectionType) = match itype.PossibleTypes with - | Some trefs -> trefs |> Array.map (getSchemaType >> resolveProvidedType) - | None -> [||] + | ValueSome trefs -> trefs |> Array.map (getSchemaType >> resolveProvidedType) + | ValueNone -> [||] let getProvidedType typeName = match providedTypes.Value.TryFind(typeName) with | Some ptype -> ptype @@ -833,16 +833,16 @@ module internal Provider = | Query -> schema.QueryType | Mutation -> match schema.MutationType with - | Some tref -> tref - | None -> failwith "The operation is a mutation operation, but the schema does not have a mutation type." + | ValueSome tref -> tref + | ValueNone -> failwith "The operation is a mutation operation, but the schema does not have a mutation type." | Subscription -> match schema.SubscriptionType with - | Some tref -> tref - | None -> failwithf "The operation is a subscription operation, but the schema does not have a subscription type." + | ValueSome tref -> tref + | ValueNone -> failwithf "The operation is a subscription operation, but the schema does not have a subscription type." let tinst = match tref.Name with - | Some name -> schema.Types |> Array.tryFind (fun t -> t.Name = name) - | None -> None + | ValueSome name -> schema.Types |> Array.tryFind (fun t -> t.Name = name) + | ValueNone -> None match tinst with | Some t -> { tref with Kind = t.Kind } | None -> failwith "The operation was found in the schema, but it does not have a name." @@ -857,8 +857,8 @@ module internal Provider = let metadata = getOperationMetadata(schemaTypes, uploadInputTypeName, enumProvidedTypes, operationAstFields, operationTypeRef, explicitOptionalParameters) let operationTypeName : TypeName = match operationTypeRef.Name with - | Some name -> name - | None -> failwith "Error parsing query. Operation type does not have a name." + | ValueSome name -> name + | ValueNone -> failwith "Error parsing query. Operation type does not have a name." let rec getKind (tref : IntrospectionTypeRef) = match tref.Kind with | TypeKind.NON_NULL | TypeKind.LIST when tref.OfType.IsSome -> getKind tref.OfType.Value @@ -868,8 +868,8 @@ module internal Provider = | TypeKind.NON_NULL | TypeKind.LIST when tref.OfType.IsSome -> getTypeName tref.OfType.Value | _ -> match tref.Name with - | Some tname -> tname - | None -> failwithf "Expected type kind \"%s\" to have a name, but it does not have a name." (tref.Kind.ToString()) + | ValueSome tname -> tname + | ValueNone -> failwithf "Expected type kind \"%s\" to have a name, but it does not have a name." (tref.Kind.ToString()) let rec getIntrospectionType (tref : IntrospectionTypeRef) = match tref.Kind with | TypeKind.NON_NULL | TypeKind.LIST when tref.OfType.IsSome -> getIntrospectionType tref.OfType.Value @@ -891,7 +891,7 @@ module internal Provider = | FragmentField fragf -> let fragmentType = let tref = - Option.defaultValue [||] introspectionType.PossibleTypes + ValueOption.defaultValue [||] introspectionType.PossibleTypes |> Array.map getIntrospectionType |> Array.append [|introspectionType|] |> Array.tryFind (fun pt -> pt.Name = fragf.TypeCondition) @@ -900,19 +900,17 @@ module internal Provider = | None -> failwithf "Fragment field defines a type condition \"%s\", but that type was not found in the schema definition." fragf.TypeCondition let field = fragmentType.Fields - |> Option.map (Array.tryFind (fun f -> f.Name = fragf.Name)) - |> Option.flatten + |> ValueOption.bind (Array.tryFind (fun f -> f.Name = fragf.Name) >> ValueOption.ofOption) match field with - | Some f -> f.Type - | None -> throw fragmentType.Name + | ValueSome f -> f.Type + | ValueNone -> throw fragmentType.Name | TypeField typef -> let field = introspectionType.Fields - |> Option.map (Array.tryFind (fun f -> f.Name = typef.Name)) - |> Option.flatten + |> ValueOption.bind (Array.tryFind (fun f -> f.Name = typef.Name) >> ValueOption.ofOption) match field with - | Some f -> f.Type - | None -> throw introspectionType.Name + | ValueSome f -> f.Type + | ValueNone -> throw introspectionType.Name let fields = match getKind tref with | TypeKind.OBJECT | TypeKind.INTERFACE | TypeKind.UNION -> diff --git a/src/FSharp.Data.GraphQL.Client/BaseTypes.fs b/src/FSharp.Data.GraphQL.Client/BaseTypes.fs index 18a43db3c..ce527ebbc 100644 --- a/src/FSharp.Data.GraphQL.Client/BaseTypes.fs +++ b/src/FSharp.Data.GraphQL.Client/BaseTypes.fs @@ -322,8 +322,8 @@ module internal JsonValueHelper = | Some t -> t | None -> typeof match typeRef.Name with - | Some name -> getType name - | None -> failwith "Expected scalar type to have a name, but it does not have one." + | ValueSome name -> getType name + | ValueNone -> failwith "Expected scalar type to have a name, but it does not have one." let rec helper (useOption : bool) (schemaField : SchemaFieldInfo) (fieldValue : JsonValue) : obj = let makeSomeIfNeeded value = match schemaField.SchemaTypeRef.Kind with @@ -344,22 +344,22 @@ module internal JsonValueHelper = | TypeKind.LIST -> schemaField.SchemaTypeRef.OfType | TypeKind.NON_NULL -> match schemaField.SchemaTypeRef.OfType with - | Some t when t.Kind = TypeKind.LIST -> t.OfType + | ValueSome t when t.Kind = TypeKind.LIST -> t.OfType | _ -> failwithf "Expected field to be a list type with an underlying item, but it is %A." schemaField.SchemaTypeRef.OfType | _ -> failwithf "Expected field to be a list type with an underlying item, but it is %A." schemaField.SchemaTypeRef match tref with - | Some t -> t - | None -> failwith "Schema type is a list type, but no underlying type was specified." + | ValueSome t -> t + | ValueNone -> failwith "Schema type is a list type, but no underlying type was specified." let items = let schemaField = { schemaField with SchemaTypeRef = itemType } items |> Array.map (helper false schemaField) match itemType.Kind with | TypeKind.NON_NULL -> match itemType.OfType with - | Some itemType -> + | ValueSome itemType -> match itemType.Kind with | TypeKind.NON_NULL -> failwith "Schema definition is not supported: a non null type of a non null type was specified." | TypeKind.OBJECT @@ -368,7 +368,7 @@ module internal JsonValueHelper = | TypeKind.ENUM -> makeArray typeof items | TypeKind.SCALAR -> makeArray (getScalarType itemType) items | kind -> failwithf "Unsupported type kind \"%A\"." kind - | None -> failwith "Item type is a non null type, but no underlying type exists on the schema definition of the type." + | ValueNone -> failwith "Item type is a non null type, but no underlying type exists on the schema definition of the type." | TypeKind.OBJECT | TypeKind.INTERFACE | TypeKind.UNION -> makeOptionArray typeof items @@ -417,19 +417,19 @@ module internal JsonValueHelper = match schemaField.SchemaTypeRef.Kind with | TypeKind.NON_NULL -> match schemaField.SchemaTypeRef.OfType with - | Some itemType -> + | ValueSome itemType -> match itemType.Kind with | TypeKind.NON_NULL -> failwith "Schema definition is not supported: a non null type of a non null type was specified." | TypeKind.SCALAR -> match itemType.Name with - | Some "URI" -> System.Uri (s) |> box - | Some "Date" -> + | ValueSome "URI" -> System.Uri (s) |> box + | ValueSome "Date" -> match DateTime.TryParse (s, CultureInfo.InvariantCulture, DateTimeStyles.None) with | (true, d) -> box d | _ -> failwith "A string was received in the query response, and the schema recognizes it as a date and time string, but the conversion failed." - | Some _ -> box s + | ValueSome _ -> box s | _ -> failwith "A string type was received in the query response item, but the matching schema field is not a string based type." @@ -437,19 +437,19 @@ module internal JsonValueHelper = | _ -> failwith "A string type was received in the query response item, but the matching schema field is not a string or an enum type." - | None -> failwith "Item type is a non null type, but no underlying type exists on the schema definition of the type." + | ValueNone -> failwith "Item type is a non null type, but no underlying type exists on the schema definition of the type." | TypeKind.SCALAR -> match schemaField.SchemaTypeRef.Name with - | Some "String" - | Some "ID" -> s |> makeSomeIfNeeded - | Some "URI" -> s |> System.Uri |> makeSomeIfNeeded - | Some "Date" -> + | ValueSome "String" + | ValueSome "ID" -> s |> makeSomeIfNeeded + | ValueSome "URI" -> s |> System.Uri |> makeSomeIfNeeded + | ValueSome "Date" -> match DateTime.TryParse (s, CultureInfo.InvariantCulture, DateTimeStyles.None) with | (true, d) -> makeSomeIfNeeded d | _ -> failwith "A string was received in the query response, and the schema recognizes it as a date and time string, but the conversion failed." - | Some _ -> s |> makeSomeIfNeeded + | ValueSome _ -> s |> makeSomeIfNeeded | _ -> failwith "A string type was received in the query response item, but the matching schema field is not a string based type." | TypeKind.ENUM when schemaField.SchemaTypeRef.Name.IsSome -> EnumBase (schemaField.SchemaTypeRef.Name.Value, s) diff --git a/src/FSharp.Data.GraphQL.Client/Serialization.fs b/src/FSharp.Data.GraphQL.Client/Serialization.fs index 22fb098c1..4939c5ee0 100644 --- a/src/FSharp.Data.GraphQL.Client/Serialization.fs +++ b/src/FSharp.Data.GraphQL.Client/Serialization.fs @@ -96,7 +96,7 @@ module Serialization = | Option t -> getArrayValue t converter items |> makeOption t | ValueOption t -> getArrayValue t converter items |> makeValueOption t | Array itype | Seq itype -> items |> Array.map (converter itype) |> castArray itype - | List itype -> items |> Array.map (converter itype) |> Array.toList |> castList itype + | List itype -> items |> Seq.map (converter itype) |> Seq.toList |> castList itype | _ -> failwith $"Error parsing JSON value: %O{t} is not an array type.") let private downcastNumber (t : Type) n = @@ -114,7 +114,7 @@ module Serialization = | JsonValue.Record jprops -> let jprops = jprops - |> Array.map (fun (n, v) -> n.ToLowerInvariant(), v) + |> Seq.map (fun (n, v) -> n.ToLowerInvariant(), v) |> Map.ofSeq let tprops t = FSharpType.GetRecordFields(t, true) diff --git a/src/FSharp.Data.GraphQL.Server.Middleware/SchemaDefinitions.fs b/src/FSharp.Data.GraphQL.Server.Middleware/SchemaDefinitions.fs index 8953828e2..d1976a5cc 100644 --- a/src/FSharp.Data.GraphQL.Server.Middleware/SchemaDefinitions.fs +++ b/src/FSharp.Data.GraphQL.Server.Middleware/SchemaDefinitions.fs @@ -179,7 +179,7 @@ let rec private coerceObjectListFilterInput (variables : Variables) inputValue : let ObjectListFilterType : InputCustomDefinition = { Name = "ObjectListFilter" Description = - Some + ValueSome (String.concat " " [ diff --git a/src/FSharp.Data.GraphQL.Server/Execution.fs b/src/FSharp.Data.GraphQL.Server/Execution.fs index 194e70969..e3ae82df9 100644 --- a/src/FSharp.Data.GraphQL.Server/Execution.fs +++ b/src/FSharp.Data.GraphQL.Server/Execution.fs @@ -27,15 +27,15 @@ let (|RequestError|Direct|Deferred|Stream|) (response : GQLExecutionResult) = let private collectDefaultArgValue acc (argDef: InputFieldDef) = match argDef.DefaultValue with - | Some defVal -> Map.add argDef.Name defVal acc - | None -> acc + | ValueSome defVal -> Map.add argDef.Name defVal acc + | ValueNone -> acc let internal argumentValue inputContext variables (argDef: InputFieldDef) (argument: Argument) = match argDef.ExecuteInput inputContext argument.Value variables with | Ok null -> match argDef.DefaultValue with - | Some value -> Ok value - | None -> Ok null + | ValueSome value -> Ok value + | ValueNone -> Ok null | result -> result let private getArgumentValues (argDefs: InputFieldDef []) (args: Argument list) (inputContext : InputExecutionContextProvider) (variables: ImmutableDictionary) : Result, IGQLError list> = @@ -77,18 +77,18 @@ let private defaultResolveType possibleTypesFn abstractDef : obj -> ObjectDef = possibleTypes |> Array.find (fun objdef -> match objdef.IsTypeOf with - | Some isTypeOf -> isTypeOf mapped - | None -> false) + | ValueSome isTypeOf -> isTypeOf mapped + | ValueNone -> false) let private resolveInterfaceType possibleTypesFn (interfacedef: InterfaceDef) = match interfacedef.ResolveType with - | Some resolveType -> resolveType - | None -> defaultResolveType possibleTypesFn interfacedef + | ValueSome resolveType -> resolveType + | ValueNone -> defaultResolveType possibleTypesFn interfacedef let private resolveUnionType possibleTypesFn (uniondef: UnionDef) = match uniondef.ResolveType with - | Some resolveType -> resolveType - | None -> defaultResolveType possibleTypesFn uniondef + | ValueSome resolveType -> resolveType + | ValueNone -> defaultResolveType possibleTypesFn uniondef let private createFieldContext objdef inputContext argDefs ctx (info: ExecutionInfo) (path : FieldPath) = result { let fdef = info.Definition diff --git a/src/FSharp.Data.GraphQL.Server/Linq.fs b/src/FSharp.Data.GraphQL.Server/Linq.fs index 4450b8e49..2f24b3663 100644 --- a/src/FSharp.Data.GraphQL.Server/Linq.fs +++ b/src/FSharp.Data.GraphQL.Server/Linq.fs @@ -103,13 +103,13 @@ let inline private argVal inputContext vars argDef argOpt = Execution.argumentValue inputContext vars argDef arg // TODO: Improve error propagation |> Result.defaultWith (failwithf "%A") - |> Some + |> ValueSome | None -> argDef.DefaultValue /// Resolves an object representing one of the supported arguments /// given a variables set and GraphQL input data. let private resolveLinqArg inputContext vars (name, argDef, arg) = - argVal inputContext vars argDef arg |> Option.map (fun v -> { Arg.Name = name; Value = v }) + argVal inputContext vars argDef arg |> ValueOption.map (fun v -> { Arg.Name = name; Value = v }) let rec private unwrapType = function @@ -272,8 +272,8 @@ let private linqArgs inputContext vars info = let args = info.Ast.Arguments argDefs |> Array.map (fun a -> (a.Name, a, args |> List.tryFind (fun x -> x.Name = a.Name))) - |> Array.choose (resolveLinqArg inputContext vars) - |> Array.toList + |> Seq.vchoose (resolveLinqArg inputContext vars) + |> Seq.toList let rec private track set e = match e with diff --git a/src/FSharp.Data.GraphQL.Server/Planning.fs b/src/FSharp.Data.GraphQL.Server/Planning.fs index 9a5a5d533..dcd863137 100644 --- a/src/FSharp.Data.GraphQL.Server/Planning.fs +++ b/src/FSharp.Data.GraphQL.Server/Planning.fs @@ -30,10 +30,10 @@ let TypeMetaFieldDef = typedef = StructNullable __Type, args = [ { Name = "name" - Description = None + Description = ValueNone IsSkippable = false TypeDef = StringType - DefaultValue = None + DefaultValue = ValueNone ExecuteInput = variableOrElse(InlineConstant >> coerceStringInput >> Result.map box) } ], resolve = fun ctx (_:obj) -> diff --git a/src/FSharp.Data.GraphQL.Server/Schema.fs b/src/FSharp.Data.GraphQL.Server/Schema.fs index 1aca8292a..6c5ddc470 100644 --- a/src/FSharp.Data.GraphQL.Server/Schema.fs +++ b/src/FSharp.Data.GraphQL.Server/Schema.fs @@ -237,10 +237,10 @@ type Schema<'Root> (query: ObjectDef<'Root>, ?mutation: ObjectDef<'Root>, ?subsc | x -> x let defaultValue = inputDef.DefaultValue - |> Option.map (fun value -> JsonSerializer.Serialize(unwrap value, schemaConfig.JsonOptions)) + |> ValueOption.map (fun value -> JsonSerializer.Serialize(unwrap value, schemaConfig.JsonOptions)) { Name = inputDef.Name Description = inputDef.Description - Type = introspectTypeRef (Option.isSome inputDef.DefaultValue) namedTypes inputDef.TypeDef + Type = introspectTypeRef (ValueOption.isSome inputDef.DefaultValue) namedTypes inputDef.TypeDef DefaultValue = defaultValue } let introspectField (namedTypes: Map) (fdef: FieldDef) = @@ -248,7 +248,7 @@ type Schema<'Root> (query: ObjectDef<'Root>, ?mutation: ObjectDef<'Root>, ?subsc Description = fdef.Description Args = fdef.Args |> Array.map (introspectInput namedTypes) Type = introspectTypeRef false namedTypes fdef.TypeDef - IsDeprecated = Option.isSome fdef.DeprecationReason + IsDeprecated = ValueOption.isSome fdef.DeprecationReason DeprecationReason = fdef.DeprecationReason } let instrospectSubscriptionField (namedTypes: Map) (subdef: SubscriptionFieldDef) = @@ -256,13 +256,13 @@ type Schema<'Root> (query: ObjectDef<'Root>, ?mutation: ObjectDef<'Root>, ?subsc Description = subdef.Description Args = subdef.Args |> Array.map (introspectInput namedTypes) Type = introspectTypeRef false namedTypes subdef.OutputTypeDef - IsDeprecated = Option.isSome subdef.DeprecationReason + IsDeprecated = ValueOption.isSome subdef.DeprecationReason DeprecationReason = subdef.DeprecationReason } let introspectEnumVal (enumVal: EnumVal) : IntrospectionEnumVal = { Name = enumVal.Name Description = enumVal.Description - IsDeprecated = Option.isSome enumVal.DeprecationReason + IsDeprecated = ValueOption.isSome enumVal.DeprecationReason DeprecationReason = enumVal.DeprecationReason } let locationToList location = @@ -331,13 +331,13 @@ type Schema<'Root> (query: ObjectDef<'Root>, ?mutation: ObjectDef<'Root>, ?subsc types.ToSeq() |> Seq.map (fun (typeName, typedef) -> match typedef with - | Scalar x -> typeName, { Kind = TypeKind.SCALAR; Name = Some typeName; Description = x.Description; OfType = None } - | Object x -> typeName, { Kind = TypeKind.OBJECT; Name = Some typeName; Description = x.Description; OfType = None } - | InputObject x -> typeName, { Kind = TypeKind.INPUT_OBJECT; Name = Some typeName; Description = x.Description; OfType = None } - | Union x -> typeName, { Kind = TypeKind.UNION; Name = Some typeName; Description = x.Description; OfType = None } - | Enum x -> typeName, { Kind = TypeKind.ENUM; Name = Some typeName; Description = x.Description; OfType = None } - | Interface x -> typeName, { Kind = TypeKind.INTERFACE; Name = Some typeName; Description = x.Description; OfType = None } - | InputCustom x -> typeName, { Kind = TypeKind.INPUT_OBJECT; Name = Some typeName; Description = x.Description; OfType = None } + | Scalar x -> typeName, { Kind = TypeKind.SCALAR; Name = ValueSome typeName; Description = x.Description; OfType = ValueNone } + | Object x -> typeName, { Kind = TypeKind.OBJECT; Name = ValueSome typeName; Description = x.Description; OfType = ValueNone } + | InputObject x -> typeName, { Kind = TypeKind.INPUT_OBJECT; Name = ValueSome typeName; Description = x.Description; OfType = ValueNone } + | Union x -> typeName, { Kind = TypeKind.UNION; Name = ValueSome typeName; Description = x.Description; OfType = ValueNone } + | Enum x -> typeName, { Kind = TypeKind.ENUM; Name = ValueSome typeName; Description = x.Description; OfType = ValueNone } + | Interface x -> typeName, { Kind = TypeKind.INTERFACE; Name = ValueSome typeName; Description = x.Description; OfType = ValueNone } + | InputCustom x -> typeName, { Kind = TypeKind.INPUT_OBJECT; Name = ValueSome typeName; Description = x.Description; OfType = ValueNone } | _ -> failwithf "Unexpected value of typedef: %O" typedef) |> Map.ofSeq let itypes = @@ -349,8 +349,9 @@ type Schema<'Root> (query: ObjectDef<'Root>, ?mutation: ObjectDef<'Root>, ?subsc |> List.map (introspectDirective inamed) |> List.toArray { QueryType = Map.find query.Name inamed - MutationType = mutation |> Option.map (fun m -> Map.find m.Name inamed) - SubscriptionType = subscription |> Option.map(fun s -> Map.find s.Name inamed) + // TODO: `mutation`/`subscription` are still `'T option` (Schema's constructor is out of scope for this change) - convert here until that follow-up moves Schema to [] ?. + MutationType = mutation |> ValueOption.ofOption |> ValueOption.map (fun m -> Map.find m.Name inamed) + SubscriptionType = subscription |> ValueOption.ofOption |> ValueOption.map(fun s -> Map.find s.Name inamed) Types = itypes Directives = idirectives } diff --git a/src/FSharp.Data.GraphQL.Server/Values.fs b/src/FSharp.Data.GraphQL.Server/Values.fs index 431e104b3..87f3f8f9a 100644 --- a/src/FSharp.Data.GraphQL.Server/Values.fs +++ b/src/FSharp.Data.GraphQL.Server/Values.fs @@ -654,8 +654,8 @@ and private coerceVariableInputObject (ctx : CoerceVariableInputContext, getInpu | false, _ when field.IsSkippable -> ValueNone | false, _ -> match field.DefaultValue with - | Some value -> KeyValuePair (field.Name, Ok value) - | None -> coerce (JsonDocument.Parse("null").RootElement) + | ValueSome value -> KeyValuePair (field.Name, Ok value) + | ValueNone -> coerce (JsonDocument.Parse("null").RootElement) |> ValueSome) |> ImmutableDictionary.CreateRange diff --git a/src/FSharp.Data.GraphQL.Shared/Introspection.fs b/src/FSharp.Data.GraphQL.Shared/Introspection.fs index cefebc018..1ab4f2322 100644 --- a/src/FSharp.Data.GraphQL.Shared/Introspection.fs +++ b/src/FSharp.Data.GraphQL.Shared/Introspection.fs @@ -90,75 +90,75 @@ let rec __Type = fieldsFn = fun () -> [ Define.Field ("kind", __TypeKind, (fun _ t -> t.Kind)) - Define.Field ("name", Nullable StringType, resolve = (fun _ t -> t.Name)) - Define.Field ("description", Nullable StringType, resolve = (fun _ t -> t.Description)) + Define.Field ("name", StructNullable StringType, resolve = (fun _ t -> t.Name)) + Define.Field ("description", StructNullable StringType, resolve = (fun _ t -> t.Description)) Define.Field ( "fields", - Nullable (ListOf __Field), + StructNullable (ListOf __Field), args = [ Define.Input ("includeDeprecated", BooleanType, false) ], resolve = fun ctx t -> match t.Name with - | None -> None - | Some name -> + | ValueNone -> ValueNone + | ValueSome name -> let found = findIntrospected ctx name match ctx.TryArg "includeDeprecated" with - | ValueSome true -> found.Fields |> Option.map Array.toSeq + | ValueSome true -> found.Fields |> ValueOption.map Array.toSeq | _ -> found.Fields - |> Option.map (fun x -> upcast Array.filter (fun f -> not f.IsDeprecated) x) + |> ValueOption.map (fun x -> upcast Array.filter (fun f -> not f.IsDeprecated) x) ) Define.Field ( "interfaces", - Nullable (ListOf __Type), + StructNullable (ListOf __Type), resolve = fun ctx t -> match t.Name with - | None -> None - | Some name -> + | ValueNone -> ValueNone + | ValueSome name -> let found = findIntrospected ctx name - found.Interfaces |> Option.map Array.toSeq + found.Interfaces |> ValueOption.map Array.toSeq ) Define.Field ( "possibleTypes", - Nullable (ListOf __Type), + StructNullable (ListOf __Type), resolve = fun ctx t -> match t.Name with - | None -> None - | Some name -> + | ValueNone -> ValueNone + | ValueSome name -> let found = findIntrospected ctx name - found.PossibleTypes |> Option.map Array.toSeq + found.PossibleTypes |> ValueOption.map Array.toSeq ) Define.Field ( "enumValues", - Nullable (ListOf __EnumValue), + StructNullable (ListOf __EnumValue), args = [ Define.Input ("includeDeprecated", BooleanType, false) ], resolve = fun ctx t -> match t.Name with - | None -> None - | Some name -> + | ValueNone -> ValueNone + | ValueSome name -> let found = findIntrospected ctx name match ctx.TryArg "includeDeprecated" with | ValueNone - | ValueSome false -> found.EnumValues |> Option.map Array.toSeq + | ValueSome false -> found.EnumValues |> ValueOption.map Array.toSeq | ValueSome true -> found.EnumValues - |> Option.map (fun x -> upcast (x |> Array.filter (fun f -> not f.IsDeprecated))) + |> ValueOption.map (fun x -> upcast (x |> Array.filter (fun f -> not f.IsDeprecated))) ) Define.Field ( "inputFields", - Nullable (ListOf __InputValue), + StructNullable (ListOf __InputValue), resolve = fun ctx t -> match t.Name with - | None -> None - | Some name -> + | ValueNone -> ValueNone + | ValueSome name -> let found = findIntrospected ctx name - found.InputFields |> Option.map Array.toSeq + found.InputFields |> ValueOption.map Array.toSeq ) - Define.Field ("ofType", Nullable __Type, resolve = (fun _ t -> t.OfType)) + Define.Field ("ofType", StructNullable __Type, resolve = (fun _ t -> t.OfType)) ] ) @@ -173,9 +173,9 @@ and __InputValue = fieldsFn = fun () -> [ Define.Field ("name", StringType, resolve = (fun _ f -> f.Name)) - Define.Field ("description", Nullable StringType, resolve = (fun _ f -> f.Description)) + Define.Field ("description", StructNullable StringType, resolve = (fun _ f -> f.Description)) Define.Field ("type", __Type, resolve = (fun _ f -> f.Type)) - Define.Field ("defaultValue", Nullable StringType, (fun _ f -> f.DefaultValue)) + Define.Field ("defaultValue", StructNullable StringType, (fun _ f -> f.DefaultValue)) ] ) @@ -189,11 +189,11 @@ and __Field = fieldsFn = fun () -> [ Define.Field ("name", StringType, (fun _ f -> f.Name)) - Define.Field ("description", Nullable StringType, (fun _ f -> f.Description)) + Define.Field ("description", StructNullable StringType, (fun _ f -> f.Description)) Define.Field ("args", ListOf __InputValue, (fun _ f -> f.Args)) Define.Field ("type", __Type, (fun _ f -> f.Type)) Define.Field ("isDeprecated", BooleanType, resolve = (fun _ f -> f.IsDeprecated)) - Define.Field ("deprecationReason", Nullable StringType, (fun _ f -> f.DeprecationReason)) + Define.Field ("deprecationReason", StructNullable StringType, (fun _ f -> f.DeprecationReason)) ] ) @@ -208,9 +208,9 @@ and __EnumValue = fieldsFn = fun () -> [ Define.Field ("name", StringType, resolve = (fun _ e -> e.Name)) - Define.Field ("description", Nullable StringType, resolve = (fun _ e -> e.Description)) - Define.Field ("isDeprecated", BooleanType, resolve = (fun _ e -> Option.isSome e.DeprecationReason)) - Define.Field ("deprecationReason", Nullable StringType, resolve = (fun _ e -> e.DeprecationReason)) + Define.Field ("description", StructNullable StringType, resolve = (fun _ e -> e.Description)) + Define.Field ("isDeprecated", BooleanType, resolve = (fun _ e -> ValueOption.isSome e.DeprecationReason)) + Define.Field ("deprecationReason", StructNullable StringType, resolve = (fun _ e -> e.DeprecationReason)) ] ) @@ -231,7 +231,7 @@ and __Directive = fieldsFn = fun () -> [ Define.Field ("name", StringType, resolve = (fun _ directive -> directive.Name)) - Define.Field ("description", Nullable StringType, resolve = (fun _ directive -> directive.Description)) + Define.Field ("description", StructNullable StringType, resolve = (fun _ directive -> directive.Description)) Define.Field ("locations", ListOf __DirectiveLocation, resolve = (fun _ directive -> directive.Locations)) Define.Field ("args", ListOf __InputValue, resolve = (fun _ directive -> directive.Args)) Define.Field ( @@ -291,13 +291,13 @@ and __Schema = ) Define.Field ( "mutationType", - Nullable __Type, + StructNullable __Type, description = "If this server supports mutation, the type that mutation operations will be rooted at.", resolve = fun _ schema -> schema.MutationType ) Define.Field ( "subscriptionType", - Nullable __Type, + StructNullable __Type, description = "If this server support subscription, the type that subscription operations will be rooted at.", resolve = fun _ schema -> schema.SubscriptionType ) diff --git a/src/FSharp.Data.GraphQL.Shared/SchemaDefinitions.fs b/src/FSharp.Data.GraphQL.Shared/SchemaDefinitions.fs index 112bf27fa..a87693488 100644 --- a/src/FSharp.Data.GraphQL.Shared/SchemaDefinitions.fs +++ b/src/FSharp.Data.GraphQL.Shared/SchemaDefinitions.fs @@ -474,7 +474,7 @@ module SchemaDefinitions = let IntType : ScalarDefinition = { Name = "Int" Description = - Some + ValueSome "The `Int` scalar type represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1." CoerceInput = coerceIntInput CoerceOutput = coerceIntValue } @@ -483,7 +483,7 @@ module SchemaDefinitions = let LongType : ScalarDefinition = { Name = "Long" Description = - Some + ValueSome "The `Long` scalar type represents non-fractional signed whole numeric values. Long can represent values between -(2^63) and 2^63 - 1." CoerceInput = coerceLongInput CoerceOutput = coerceLongValue } @@ -491,7 +491,7 @@ module SchemaDefinitions = /// GraphQL type of boolean let BooleanType : ScalarDefinition = { Name = "Boolean" - Description = Some "The `Boolean` scalar type represents `true` or `false`." + Description = ValueSome "The `Boolean` scalar type represents `true` or `false`." CoerceInput = coerceBoolInput CoerceOutput = coerceBoolValue } @@ -499,7 +499,7 @@ module SchemaDefinitions = let FloatType : ScalarDefinition = { Name = "Float" Description = - Some + ValueSome "The `Float` scalar type represents signed double-precision fractional values as specified by [IEEE 754](http://en.wikipedia.org/wiki/IEEE_floating_point)." CoerceInput = coerceFloatInput CoerceOutput = coerceFloatValue } @@ -508,7 +508,7 @@ module SchemaDefinitions = let StringType : ScalarDefinition = { Name = "String" Description = - Some + ValueSome "The `String` scalar type represents textual data, represented as UTF-8 character sequences. The `String` type is most often used by GraphQL to represent free-form human-readable text." CoerceInput = coerceStringInput CoerceOutput = coerceStringValue } @@ -517,7 +517,7 @@ module SchemaDefinitions = let IDType : ScalarDefinition = { Name = "ID" Description = - Some + ValueSome "The `ID` scalar type represents a unique identifier, often used to refetch an object or as key for a cache. The `ID` type appears in a JSON response as a String; however, it is not intended to be human-readable. When expected as an input type, any string (such as `\"4\"`) or integer (such as `4`) input value will be accepted as an ID." CoerceInput = coerceIdInput CoerceOutput = coerceIdValue } @@ -525,7 +525,7 @@ module SchemaDefinitions = let ObjType : ScalarDefinition = { Name = "Object" Description = - Some + ValueSome "The `Object` scalar type represents textual data, represented as UTF-8 character sequences. The `String` type is most often used by GraphQL to represent free-form human-readable text." CoerceInput = (fun o -> Ok (o)) CoerceOutput = (fun o -> Some (o)) @@ -535,7 +535,7 @@ module SchemaDefinitions = let UriType : ScalarDefinition = { Name = "URI" Description = - Some + ValueSome "The `URI` scalar type represents a string resource identifier compatible with URI standard. The `URI` type appears in a JSON response as a String." CoerceInput = coerceUriInput CoerceOutput = coerceUriValue } @@ -544,7 +544,7 @@ module SchemaDefinitions = let DateTimeOffsetType : ScalarDefinition = { Name = "DateTimeOffset" Description = - Some + ValueSome "The `DateTimeOffset` scalar type represents a Date value with Time component. The `DateTimeOffset` type appears in a JSON response as a String representation compatible with ISO-8601 format." CoerceInput = coerceDateTimeOffsetInput CoerceOutput = coerceDateTimeOffsetValue } @@ -553,7 +553,7 @@ module SchemaDefinitions = let DateOnlyType : ScalarDefinition = { Name = "DateOnly" Description = - Some + ValueSome "The `DateOnly` scalar type represents a Date value without Time component. The `DateOnly` type appears in a JSON response as a `String` representation of full-date value as specified by [IETF 3339](https://www.ietf.org/rfc/rfc3339.txt)." CoerceInput = coerceDateOnlyInput CoerceOutput = coerceDateOnlyValue } @@ -562,7 +562,7 @@ module SchemaDefinitions = let TimeOnlyType : ScalarDefinition = { Name = "TimeOnly" Description = - Some + ValueSome "The `TimeOnly` scalar type represents a Time value without Date component. The `TimeOnly` type appears in a JSON response as a `String` representation of full-time value as specified by [IETF 3339](https://www.ietf.org/rfc/rfc3339.txt)." CoerceInput = coerceTimeOnlyInput CoerceOutput = coerceTimeOnlyValue } @@ -571,7 +571,7 @@ module SchemaDefinitions = let GuidType : ScalarDefinition = { Name = "Guid" Description = - Some + ValueSome "The `Guid` scalar type represents a Globally Unique Identifier value. It's a 128-bit long byte key, that can be serialized to string." CoerceInput = coerceGuidInput CoerceOutput = coerceGuidValue } @@ -580,7 +580,7 @@ module SchemaDefinitions = let FileType : InputCustomDefinition = { Name = "File" Description = - Some + ValueSome "The `File` type represents a file on one or more fields of an object in an object list. The filter is represented by a JSON object where the fields are the complemented by specific suffixes to represent a query." CoerceInput = (fun inputContext input variables -> @@ -613,35 +613,35 @@ module SchemaDefinitions = let IncludeDirective : DirectiveDef = { Name = "include" Description = - Some "Directs the executor to include this field or fragment only when the `if` argument is true." + ValueSome "Directs the executor to include this field or fragment only when the `if` argument is true." Locations = DirectiveLocation.FIELD ||| DirectiveLocation.FRAGMENT_SPREAD ||| DirectiveLocation.INLINE_FRAGMENT Args = [| { InputFieldDefinition.Name = "if" - Description = Some "Included when true." + Description = ValueSome "Included when true." IsSkippable = false TypeDef = BooleanType - DefaultValue = None + DefaultValue = ValueNone ExecuteInput = variableOrElse (InlineConstant >> coerceBoolInput >> Result.map box) } |] } /// GraphQL @skip directive. let SkipDirective : DirectiveDef = { Name = "skip" - Description = Some "Directs the executor to skip this field or fragment when the `if` argument is true." + Description = ValueSome "Directs the executor to skip this field or fragment when the `if` argument is true." Locations = DirectiveLocation.FIELD ||| DirectiveLocation.FRAGMENT_SPREAD ||| DirectiveLocation.INLINE_FRAGMENT Args = [| { InputFieldDefinition.Name = "if" - Description = Some "Skipped when true." + Description = ValueSome "Skipped when true." IsSkippable = false TypeDef = BooleanType - DefaultValue = None + DefaultValue = ValueNone ExecuteInput = variableOrElse (InlineConstant >> coerceBoolInput >> Result.map box) } |] } /// GraphQL @defer directive. let DeferDirective : DirectiveDef = { Name = "defer" - Description = Some "Defers the resolution of this field or fragment" + Description = ValueSome "Defers the resolution of this field or fragment" Locations = DirectiveLocation.FIELD ||| DirectiveLocation.FRAGMENT_SPREAD ||| DirectiveLocation.INLINE_FRAGMENT ||| DirectiveLocation.FRAGMENT_DEFINITION Args = [||] } @@ -649,7 +649,7 @@ module SchemaDefinitions = /// GraphQL @stream directive. let StreamDirective : DirectiveDef = { Name = "stream" - Description = Some "Streams the resolution of this field or fragment" + Description = ValueSome "Streams the resolution of this field or fragment" Locations = DirectiveLocation.FIELD ||| DirectiveLocation.FRAGMENT_SPREAD ||| DirectiveLocation.INLINE_FRAGMENT ||| DirectiveLocation.FRAGMENT_DEFINITION Args = [||] } @@ -657,7 +657,7 @@ module SchemaDefinitions = /// GraphQL @live directive. let LiveDirective : DirectiveDef = { Name = "live" - Description = Some "Subscribes for live updates of this field or fragment" + Description = ValueSome "Subscribes for live updates of this field or fragment" Locations = DirectiveLocation.FIELD ||| DirectiveLocation.FRAGMENT_SPREAD ||| DirectiveLocation.INLINE_FRAGMENT ||| DirectiveLocation.FRAGMENT_DEFINITION Args = [||] } @@ -676,7 +676,7 @@ module SchemaDefinitions = /// Function used to cross cast to .NET types. /// Optional scalar description. Usefull for generating documentation. static member Scalar(name : string, coerceInput : InputParameterValue -> Result<'T, string>, - coerceOutput : obj -> 'T option, ?description : string) : ScalarDefinition<'T> = + coerceOutput : obj -> 'T option, [] ?description : string) : ScalarDefinition<'T> = { Name = name Description = description CoerceInput = coerceInput >> Result.mapError (fun msg -> { new IGQLError with member _.Message = msg } |> List.singleton) @@ -690,7 +690,7 @@ module SchemaDefinitions = /// Function used to cross cast to .NET types. /// Optional scalar description. Usefull for generating documentation. static member Scalar(name : string, coerceInput : InputParameterValue -> Result<'T, string list>, - coerceOutput : obj -> 'T option, ?description : string) : ScalarDefinition<'T> = + coerceOutput : obj -> 'T option, [] ?description : string) : ScalarDefinition<'T> = { Name = name Description = description CoerceInput = coerceInput >> Result.mapError (List.map (fun msg -> { new IGQLError with member _.Message = msg })) @@ -704,7 +704,7 @@ module SchemaDefinitions = /// Function used to cross cast to .NET types. /// Optional scalar description. Usefull for generating documentation. static member Scalar(name : string, coerceInput : InputParameterValue -> Result<'T, IGQLError>, - coerceOutput : obj -> 'T option, ?description : string) : ScalarDefinition<'T> = + coerceOutput : obj -> 'T option, [] ?description : string) : ScalarDefinition<'T> = { Name = name Description = description CoerceInput = coerceInput >> Result.mapError List.singleton @@ -718,7 +718,7 @@ module SchemaDefinitions = /// Function used to cross cast to .NET types. /// Optional scalar description. Usefull for generating documentation. static member Scalar(name : string, coerceInput : InputParameterValue -> Result<'T, IGQLError list>, - coerceOutput : obj -> 'T option, ?description : string) : ScalarDefinition<'T> = + coerceOutput : obj -> 'T option, [] ?description : string) : ScalarDefinition<'T> = { Name = name Description = description CoerceInput = coerceInput @@ -732,7 +732,7 @@ module SchemaDefinitions = /// Function used to cross cast to .NET types. /// Optional scalar description. Usefull for generating documentation. static member WrappedScalar(name : string, coerceInput : InputParameterValue -> Result<'Wrapper, string>, - coerceOutput : obj -> 'Primitive option, ?description : string) : ScalarDefinition<'Primitive, 'Wrapper> = + coerceOutput : obj -> 'Primitive option, [] ?description : string) : ScalarDefinition<'Primitive, 'Wrapper> = { Name = name Description = description CoerceInput = coerceInput >> Result.mapError (fun msg -> { new IGQLError with member _.Message = msg } |> List.singleton) @@ -746,7 +746,7 @@ module SchemaDefinitions = /// Function used to cross cast to .NET types. /// Optional scalar description. Usefull for generating documentation. static member WrappedScalar(name : string, coerceInput : InputParameterValue -> Result<'Wrapper, string list>, - coerceOutput : obj -> 'Primitive option, ?description : string) : ScalarDefinition<'Primitive, 'Wrapper> = + coerceOutput : obj -> 'Primitive option, [] ?description : string) : ScalarDefinition<'Primitive, 'Wrapper> = { Name = name Description = description CoerceInput = coerceInput >> Result.mapError (List.map (fun msg -> { new IGQLError with member _.Message = msg })) @@ -760,7 +760,7 @@ module SchemaDefinitions = /// Function used to cross cast to .NET types. /// Optional scalar description. Usefull for generating documentation. static member WrappedScalar(name : string, coerceInput : InputParameterValue -> Result<'Wrapper, IGQLError>, - coerceOutput : obj -> 'Primitive option, ?description : string) : ScalarDefinition<'Primitive, 'Wrapper> = + coerceOutput : obj -> 'Primitive option, [] ?description : string) : ScalarDefinition<'Primitive, 'Wrapper> = { Name = name Description = description CoerceInput = coerceInput >> Result.mapError List.singleton @@ -774,7 +774,7 @@ module SchemaDefinitions = /// Function used to cross cast to .NET types. /// Optional scalar description. Usefull for generating documentation. static member WrappedScalar(name : string, coerceInput : InputParameterValue -> Result<'Wrapper, IGQLError list>, - coerceOutput : obj -> 'Primitive option, ?description : string) : ScalarDefinition<'Primitive, 'Wrapper> = + coerceOutput : obj -> 'Primitive option, [] ?description : string) : ScalarDefinition<'Primitive, 'Wrapper> = { Name = name Description = description CoerceInput = coerceInput @@ -786,7 +786,7 @@ module SchemaDefinitions = /// Type name. Must be unique in scope of the current schema. /// List of enum value cases. /// Optional enum description. Usefull for generating documentation. - static member Enum(name : string, options : EnumValue<'Val> list, ?description : string) : EnumDef<'Val> = + static member Enum(name : string, options : EnumValue<'Val> list, [] ?description : string) : EnumDef<'Val> = upcast { EnumDefinition.Name = name Description = description Options = options |> List.toArray } @@ -801,7 +801,7 @@ module SchemaDefinitions = /// /// Optional enum value description. Usefull for generating documentation. /// If set, marks an enum value as deprecated. - static member EnumValue(name : string, value : 'Val, ?description : string, ?deprecationReason : string) : EnumValue<'Val> = + static member EnumValue(name : string, value : 'Val, [] ?description : string, [] ?deprecationReason : string) : EnumValue<'Val> = { Name = name Description = description Value = value @@ -820,15 +820,15 @@ module SchemaDefinitions = /// /// Optional function used to determine if provided .NET object instance matches current object definition. /// - static member Object(name : string, fields : FieldDef<'Val> list, ?description : string, - ?interfaces : InterfaceDef list, ?isTypeOf : obj -> bool) : ObjectDef<'Val> = + static member Object(name : string, fields : FieldDef<'Val> list, [] ?description : string, + [] ?interfaces : InterfaceDef list, [] ?isTypeOf : obj -> bool) : ObjectDef<'Val> = upcast { ObjectDefinition.Name = name Description = description FieldsFn = lazy (fields |> List.map (fun f -> f.Name, f) |> Map.ofList) - Implements = defaultArg (Option.map List.toArray interfaces) [||] + Implements = defaultValueArg (ValueOption.map List.toArray interfaces) [||] IsTypeOf = isTypeOf } /// @@ -839,7 +839,7 @@ module SchemaDefinitions = /// Type name. Must be unique in scope of the current schema. /// List of input fields defined by the current input object. /// Optional input object description. Useful for generating documentation. - static member InputObject(name : string, fields : InputFieldDef list, ?description : string) : InputObjectDefinition<'Out> = + static member InputObject(name : string, fields : InputFieldDef list, [] ?description : string) : InputObjectDefinition<'Out> = { Name = name Description = description Fields = lazy (fields |> List.toArray) @@ -855,7 +855,7 @@ module SchemaDefinitions = /// List of input fields defined by the current input object. /// Object validator. /// Optional input object description. Useful for generating documentation. - static member InputObject(name : string, fields : InputFieldDef list, validator: GQLValidator<'Out>, ?description : string) : InputObjectDefinition<'Out> = + static member InputObject(name : string, fields : InputFieldDef list, validator: GQLValidator<'Out>, [] ?description : string) : InputObjectDefinition<'Out> = { Name = name Description = description Fields = lazy (fields |> List.toArray) @@ -868,7 +868,7 @@ module SchemaDefinitions = /// Top level name. Must be unique in scope of the current schema. /// List of subscription fields to be defined for the schema. /// Optional description. Usefull for generating documentation. - static member SubscriptionObject<'Val>(name: string, fields: SubscriptionFieldDef<'Val> list, ?description: string):SubscriptionObjectDefinition<'Val> = + static member SubscriptionObject<'Val>(name: string, fields: SubscriptionFieldDef<'Val> list, [] ?description: string):SubscriptionObjectDefinition<'Val> = { Name = name Fields = (fields |> List.map (fun f -> f.Name, f) |> Map.ofList) Description = description } @@ -882,12 +882,12 @@ module SchemaDefinitions = /// Optional field description. Usefull for generating documentation. /// Optional list of arguments used to parametrize field resolution. /// If set, marks current field as deprecated. - static member AutoField(name : string, typedef : #OutputDef<'Res>, ?description: string, ?args: InputFieldDef list, ?deprecationReason: string) : FieldDef<'Val, 'Res> = + static member AutoField(name : string, typedef : #OutputDef<'Res>, [] ?description: string, [] ?args: InputFieldDef list, [] ?deprecationReason: string) : FieldDef<'Val, 'Res> = upcast { FieldDefinition.Name = name Description = description TypeDef = typedef Resolve = Resolve.defaultResolve<'Val, 'Res> name - Args = defaultArg args [] |> Array.ofList + Args = defaultValueArg args [] |> Array.ofList DeprecationReason = deprecationReason Metadata = Metadata.Empty } @@ -898,9 +898,9 @@ module SchemaDefinitions = /// Field name. Must be unique in scope of the defining object. /// GraphQL type definition of the current field's type. /// Deprecation reason. - static member Field(name : string, typedef : #OutputDef<'Res>, ?deprecationReason : string) : FieldDef<'Val, 'Res> = + static member Field(name : string, typedef : #OutputDef<'Res>, [] ?deprecationReason : string) : FieldDef<'Val, 'Res> = upcast { FieldDefinition.Name = name - Description = None + Description = ValueNone TypeDef = typedef Resolve = Undefined Args = [||] @@ -916,9 +916,9 @@ module SchemaDefinitions = /// Deprecation reason. static member Field(name : string, typedef : #OutputDef<'Res>, [] resolve : Expr 'Val -> 'Res>, - ?deprecationReason : string) : FieldDef<'Val, 'Res> = + [] ?deprecationReason : string) : FieldDef<'Val, 'Res> = upcast { FieldDefinition.Name = name - Description = None + Description = ValueNone TypeDef = typedef Resolve = Sync(typeof<'Val>, typeof<'Res>, resolve) Args = [||] @@ -935,10 +935,10 @@ module SchemaDefinitions = /// Deprecation reason. static member Field(name : string, typedef : #OutputDef<'Res>, description : string, [] resolve : Expr 'Val -> 'Res>, - ?deprecationReason : string) : FieldDef<'Val, 'Res> = + [] ?deprecationReason : string) : FieldDef<'Val, 'Res> = upcast { FieldDefinition.Name = name - Description = Some description + Description = ValueSome description TypeDef = typedef Resolve = Sync(typeof<'Val>, typeof<'Res>, resolve) Args = [||] @@ -955,9 +955,9 @@ module SchemaDefinitions = /// Deprecation reason. static member Field(name : string, typedef : #OutputDef<'Res>, args : InputFieldDef list, [] resolve : Expr 'Val -> 'Res>, - ?deprecationReason : string) : FieldDef<'Val, 'Res> = + [] ?deprecationReason : string) : FieldDef<'Val, 'Res> = upcast { FieldDefinition.Name = name - Description = None + Description = ValueNone TypeDef = typedef Resolve = Sync(typeof<'Val>, typeof<'Res>, resolve) Args = args |> List.toArray @@ -974,9 +974,9 @@ module SchemaDefinitions = /// Expression used to resolve value from defining object. static member Field(name : string, typedef : #OutputDef<'Res>, description : string, args : InputFieldDef list, [] resolve : Expr 'Val -> 'Res>, - ?deprecationReason : string) : FieldDef<'Val, 'Res> = + [] ?deprecationReason : string) : FieldDef<'Val, 'Res> = upcast { FieldDefinition.Name = name - Description = Some description + Description = ValueSome description TypeDef = typedef Resolve = Sync(typeof<'Val>, typeof<'Res>, resolve) Args = args |> List.toArray @@ -992,9 +992,9 @@ module SchemaDefinitions = /// Deprecation reason. static member AsyncField(name : string, typedef : #OutputDef<'Res>, [] resolve : Expr 'Val -> Async<'Res>>, - ?deprecationReason : string) : FieldDef<'Val, 'Res> = + [] ?deprecationReason : string) : FieldDef<'Val, 'Res> = upcast { FieldDefinition.Name = name - Description = None + Description = ValueNone TypeDef = typedef Resolve = Async(typeof<'Val>, typeof<'Res>, resolve) Args = [||] @@ -1011,9 +1011,9 @@ module SchemaDefinitions = /// Deprecation reason. static member AsyncField(name : string, typedef : #OutputDef<'Res>, description : string, [] resolve : Expr 'Val -> Async<'Res>>, - ?deprecationReason : string) : FieldDef<'Val, 'Res> = + [] ?deprecationReason : string) : FieldDef<'Val, 'Res> = upcast { FieldDefinition.Name = name - Description = Some description + Description = ValueSome description TypeDef = typedef Resolve = Async(typeof<'Val>, typeof<'Res>, resolve) Args = [||] @@ -1030,9 +1030,9 @@ module SchemaDefinitions = /// Deprecation reason. static member AsyncField(name : string, typedef : #OutputDef<'Res>, args : InputFieldDef list, [] resolve : Expr 'Val -> Async<'Res>>, - ?deprecationReason : string) : FieldDef<'Val, 'Res> = + [] ?deprecationReason : string) : FieldDef<'Val, 'Res> = upcast { FieldDefinition.Name = name - Description = None + Description = ValueNone TypeDef = typedef Resolve = Async(typeof<'Val>, typeof<'Res>, resolve) Args = args |> List.toArray @@ -1051,9 +1051,9 @@ module SchemaDefinitions = static member AsyncField(name : string, typedef : #OutputDef<'Res>, description : string, args : InputFieldDef list, [] resolve : Expr 'Val -> Async<'Res>>, - ?deprecationReason : string) : FieldDef<'Val, 'Res> = + [] ?deprecationReason : string) : FieldDef<'Val, 'Res> = upcast { FieldDefinition.Name = name - Description = Some description + Description = ValueSome description TypeDef = typedef Resolve = Async(typeof<'Val>, typeof<'Res>, resolve) Args = args |> List.toArray @@ -1088,9 +1088,9 @@ module SchemaDefinitions = [] resolve : Expr 'Val -> IAsyncEnumerable<'Item>>, [] ?batching : StreamBatching<'Item>, [] ?maxConcurrency : int, - ?deprecationReason : string) : FieldDef<'Val, 'Item seq> = + [] ?deprecationReason : string) : FieldDef<'Val, 'Item seq> = upcast { FieldDefinition.Name = name - Description = None + Description = ValueNone TypeDef = typedef Resolve = TaskSeq(typeof<'Val>, typeof<'Item>, resolve, StreamBatching<'Item>.ToStreamingOptions (batching, maxConcurrency)) Args = [||] @@ -1126,9 +1126,9 @@ module SchemaDefinitions = [] resolve : Expr 'Val -> IAsyncEnumerable<'Item>>, [] ?batching : StreamBatching<'Item>, [] ?maxConcurrency : int, - ?deprecationReason : string) : FieldDef<'Val, 'Item seq> = + [] ?deprecationReason : string) : FieldDef<'Val, 'Item seq> = upcast { FieldDefinition.Name = name - Description = Some description + Description = ValueSome description TypeDef = typedef Resolve = TaskSeq(typeof<'Val>, typeof<'Item>, resolve, StreamBatching<'Item>.ToStreamingOptions (batching, maxConcurrency)) Args = [||] @@ -1164,9 +1164,9 @@ module SchemaDefinitions = [] resolve : Expr 'Val -> IAsyncEnumerable<'Item>>, [] ?batching : StreamBatching<'Item>, [] ?maxConcurrency : int, - ?deprecationReason : string) : FieldDef<'Val, 'Item seq> = + [] ?deprecationReason : string) : FieldDef<'Val, 'Item seq> = upcast { FieldDefinition.Name = name - Description = None + Description = ValueNone TypeDef = typedef Resolve = TaskSeq(typeof<'Val>, typeof<'Item>, resolve, StreamBatching<'Item>.ToStreamingOptions (batching, maxConcurrency)) Args = args |> List.toArray @@ -1203,9 +1203,9 @@ module SchemaDefinitions = [] resolve : Expr 'Val -> IAsyncEnumerable<'Item>>, [] ?batching : StreamBatching<'Item>, [] ?maxConcurrency : int, - ?deprecationReason : string) : FieldDef<'Val, 'Item seq> = + [] ?deprecationReason : string) : FieldDef<'Val, 'Item seq> = upcast { FieldDefinition.Name = name - Description = Some description + Description = ValueSome description TypeDef = typedef Resolve = TaskSeq(typeof<'Val>, typeof<'Item>, resolve, StreamBatching<'Item>.ToStreamingOptions (batching, maxConcurrency)) Args = args |> List.toArray @@ -1240,9 +1240,9 @@ module SchemaDefinitions = [] resolve : Expr 'Val -> IAsyncEnumerable<'Item> option>, [] ?batching : StreamBatching<'Item>, [] ?maxConcurrency : int, - ?deprecationReason : string) : FieldDef<'Val, 'Item seq option> = + [] ?deprecationReason : string) : FieldDef<'Val, 'Item seq option> = upcast { FieldDefinition.Name = name - Description = None + Description = ValueNone TypeDef = typedef Resolve = TaskSeq(typeof<'Val>, typeof<'Item>, resolve, StreamBatching<'Item>.ToStreamingOptions (batching, maxConcurrency)) Args = [||] @@ -1278,9 +1278,9 @@ module SchemaDefinitions = [] resolve : Expr 'Val -> IAsyncEnumerable<'Item> option>, [] ?batching : StreamBatching<'Item>, [] ?maxConcurrency : int, - ?deprecationReason : string) : FieldDef<'Val, 'Item seq option> = + [] ?deprecationReason : string) : FieldDef<'Val, 'Item seq option> = upcast { FieldDefinition.Name = name - Description = Some description + Description = ValueSome description TypeDef = typedef Resolve = TaskSeq(typeof<'Val>, typeof<'Item>, resolve, StreamBatching<'Item>.ToStreamingOptions (batching, maxConcurrency)) Args = [||] @@ -1316,9 +1316,9 @@ module SchemaDefinitions = [] resolve : Expr 'Val -> IAsyncEnumerable<'Item> option>, [] ?batching : StreamBatching<'Item>, [] ?maxConcurrency : int, - ?deprecationReason : string) : FieldDef<'Val, 'Item seq option> = + [] ?deprecationReason : string) : FieldDef<'Val, 'Item seq option> = upcast { FieldDefinition.Name = name - Description = None + Description = ValueNone TypeDef = typedef Resolve = TaskSeq(typeof<'Val>, typeof<'Item>, resolve, StreamBatching<'Item>.ToStreamingOptions (batching, maxConcurrency)) Args = args |> List.toArray @@ -1355,9 +1355,9 @@ module SchemaDefinitions = [] resolve : Expr 'Val -> IAsyncEnumerable<'Item> option>, [] ?batching : StreamBatching<'Item>, [] ?maxConcurrency : int, - ?deprecationReason : string) : FieldDef<'Val, 'Item seq option> = + [] ?deprecationReason : string) : FieldDef<'Val, 'Item seq option> = upcast { FieldDefinition.Name = name - Description = Some description + Description = ValueSome description TypeDef = typedef Resolve = TaskSeq(typeof<'Val>, typeof<'Item>, resolve, StreamBatching<'Item>.ToStreamingOptions (batching, maxConcurrency)) Args = args |> List.toArray @@ -1523,11 +1523,11 @@ module SchemaDefinitions = /// Expression used to execute the field. static member CustomField(name : string, [] execField : Expr) : FieldDef<'Val, obj> = upcast { FieldDefinition.Name = name - Description = None + Description = ValueNone TypeDef = ObjType Resolve = ResolveExpr(execField) Args = [||] - DeprecationReason = None + DeprecationReason = ValueNone Metadata = Metadata.Empty } /// @@ -1540,10 +1540,10 @@ module SchemaDefinitions = static member SubscriptionField(name: string, rootdef: #OutputDef<'Root>, outputdef: #OutputDef<'Output>, [] filter: Expr 'Root -> 'Input -> 'Output option>): SubscriptionFieldDef<'Root, 'Input, 'Output> = upcast { Name = name - Description = None + Description = ValueNone RootTypeDef = rootdef OutputTypeDef = outputdef - DeprecationReason = None + DeprecationReason = ValueNone Args = [||] Filter = Resolve.Filter(typeof<'Root>, typeof<'Input>, typeof<'Output>, filter) Metadata = Metadata.Empty @@ -1561,10 +1561,10 @@ module SchemaDefinitions = [] filter: Expr 'Root -> 'Input -> 'Output option>, tagsResolver : TagsResolver): SubscriptionFieldDef<'Root, 'Input, 'Output> = upcast { Name = name - Description = None + Description = ValueNone RootTypeDef = rootdef OutputTypeDef = outputdef - DeprecationReason = None + DeprecationReason = ValueNone Args = [||] Filter = Resolve.Filter(typeof<'Root>, typeof<'Input>, typeof<'Output>, filter) Metadata = Metadata.Empty @@ -1582,10 +1582,10 @@ module SchemaDefinitions = description: string, [] filter: Expr 'Root -> 'Input -> 'Output option>): SubscriptionFieldDef<'Root, 'Input, 'Output> = upcast { Name = name - Description = Some description + Description = ValueSome description RootTypeDef = rootdef OutputTypeDef = outputdef - DeprecationReason = None + DeprecationReason = ValueNone Args = [||] Filter = Resolve.Filter(typeof<'Root>, typeof<'Input>, typeof<'Output>, filter) Metadata = Metadata.Empty @@ -1605,10 +1605,10 @@ module SchemaDefinitions = [] filter: Expr 'Root -> 'Input -> 'Output option>, tagsResolver : TagsResolver): SubscriptionFieldDef<'Root, 'Input, 'Output> = upcast { Name = name - Description = Some description + Description = ValueSome description RootTypeDef = rootdef OutputTypeDef = outputdef - DeprecationReason = None + DeprecationReason = ValueNone Args = [||] Filter = Resolve.Filter(typeof<'Root>, typeof<'Input>, typeof<'Output>, filter) Metadata = Metadata.Empty @@ -1628,10 +1628,10 @@ module SchemaDefinitions = args: InputFieldDef list, [] filter: Expr 'Root -> 'Input -> 'Output option>): SubscriptionFieldDef<'Root, 'Input, 'Output> = upcast { Name = name - Description = Some description + Description = ValueSome description RootTypeDef = rootdef OutputTypeDef = outputdef - DeprecationReason = None + DeprecationReason = ValueNone Args = args |> List.toArray Filter = Resolve.Filter(typeof<'Root>, typeof<'Input>, typeof<'Output>, filter) Metadata = Metadata.Empty @@ -1653,10 +1653,10 @@ module SchemaDefinitions = [] filter: Expr 'Root -> 'Input -> 'Output option>, tagsResolver : TagsResolver): SubscriptionFieldDef<'Root, 'Input, 'Output> = upcast { Name = name - Description = Some description + Description = ValueSome description RootTypeDef = rootdef OutputTypeDef = outputdef - DeprecationReason = None + DeprecationReason = ValueNone Args = args |> List.toArray Filter = Resolve.Filter(typeof<'Root>, typeof<'Input>, typeof<'Output>, filter) Metadata = Metadata.Empty @@ -1678,10 +1678,10 @@ module SchemaDefinitions = [] filter: Expr 'Root -> 'Input -> 'Output option>, deprecationReason : string): SubscriptionFieldDef<'Root, 'Input, 'Output> = upcast { Name = name - Description = Some description + Description = ValueSome description RootTypeDef = rootdef OutputTypeDef = outputdef - DeprecationReason = Some deprecationReason + DeprecationReason = ValueSome deprecationReason Args = args |> List.toArray Filter = Resolve.Filter(typeof<'Root>, typeof<'Input>, typeof<'Output>, filter) Metadata = Metadata.Empty @@ -1705,10 +1705,10 @@ module SchemaDefinitions = tagsResolver : TagsResolver, deprecationReason : string): SubscriptionFieldDef<'Root, 'Input, 'Output> = upcast { Name = name - Description = Some description + Description = ValueSome description RootTypeDef = rootdef OutputTypeDef = outputdef - DeprecationReason = Some deprecationReason + DeprecationReason = ValueSome deprecationReason Args = args |> List.toArray Filter = Resolve.Filter(typeof<'Root>, typeof<'Input>, typeof<'Output>, filter) Metadata = Metadata.Empty @@ -1724,10 +1724,10 @@ module SchemaDefinitions = static member AsyncSubscriptionField(name: string, rootdef: #OutputDef<'Root>, outputdef: #OutputDef<'Output>, [] filter: Expr 'Root -> 'Input -> Async<'Output option>>): SubscriptionFieldDef<'Root, 'Input, 'Output> = upcast { Name = name - Description = None + Description = ValueNone RootTypeDef = rootdef OutputTypeDef = outputdef - DeprecationReason = None + DeprecationReason = ValueNone Args = [||] Filter = Resolve.AsyncFilter(typeof<'Root>, typeof<'Input>, typeof<'Output>, filter) Metadata = Metadata.Empty @@ -1745,10 +1745,10 @@ module SchemaDefinitions = [] filter: Expr 'Root -> 'Input -> Async<'Output option>>, tagsResolver : TagsResolver): SubscriptionFieldDef<'Root, 'Input, 'Output> = upcast { Name = name - Description = None + Description = ValueNone RootTypeDef = rootdef OutputTypeDef = outputdef - DeprecationReason = None + DeprecationReason = ValueNone Args = [||] Filter = Resolve.AsyncFilter(typeof<'Root>, typeof<'Input>, typeof<'Output>, filter) Metadata = Metadata.Empty @@ -1766,10 +1766,10 @@ module SchemaDefinitions = description: string, [] filter: Expr 'Root -> 'Input -> Async<'Output option>>): SubscriptionFieldDef<'Root, 'Input, 'Output> = upcast { Name = name - Description = Some description + Description = ValueSome description RootTypeDef = rootdef OutputTypeDef = outputdef - DeprecationReason = None + DeprecationReason = ValueNone Args = [||] Filter = Resolve.AsyncFilter(typeof<'Root>, typeof<'Input>, typeof<'Output>, filter) Metadata = Metadata.Empty @@ -1789,10 +1789,10 @@ module SchemaDefinitions = [] filter: Expr 'Root -> 'Input -> Async<'Output option>>, tagsResolver : TagsResolver): SubscriptionFieldDef<'Root, 'Input, 'Output> = upcast { Name = name - Description = Some description + Description = ValueSome description RootTypeDef = rootdef OutputTypeDef = outputdef - DeprecationReason = None + DeprecationReason = ValueNone Args = [||] Filter = Resolve.AsyncFilter(typeof<'Root>, typeof<'Input>, typeof<'Output>, filter) Metadata = Metadata.Empty @@ -1812,10 +1812,10 @@ module SchemaDefinitions = args: InputFieldDef list, [] filter: Expr 'Root -> 'Input -> Async<'Output option>>): SubscriptionFieldDef<'Root, 'Input, 'Output> = upcast { Name = name - Description = Some description + Description = ValueSome description RootTypeDef = rootdef OutputTypeDef = outputdef - DeprecationReason = None + DeprecationReason = ValueNone Args = args |> List.toArray Filter = Resolve.AsyncFilter(typeof<'Root>, typeof<'Input>, typeof<'Output>, filter) Metadata = Metadata.Empty @@ -1837,10 +1837,10 @@ module SchemaDefinitions = [] filter: Expr 'Root -> 'Input -> Async<'Output option>>, tagsResolver : TagsResolver): SubscriptionFieldDef<'Root, 'Input, 'Output> = upcast { Name = name - Description = Some description + Description = ValueSome description RootTypeDef = rootdef OutputTypeDef = outputdef - DeprecationReason = None + DeprecationReason = ValueNone Args = args |> List.toArray Filter = Resolve.AsyncFilter(typeof<'Root>, typeof<'Input>, typeof<'Output>, filter) Metadata = Metadata.Empty @@ -1862,10 +1862,10 @@ module SchemaDefinitions = [] filter: Expr 'Root -> 'Input -> Async<'Output option>>, deprecationReason : string): SubscriptionFieldDef<'Root, 'Input, 'Output> = upcast { Name = name - Description = Some description + Description = ValueSome description RootTypeDef = rootdef OutputTypeDef = outputdef - DeprecationReason = Some deprecationReason + DeprecationReason = ValueSome deprecationReason Args = args |> List.toArray Filter = Resolve.AsyncFilter(typeof<'Root>, typeof<'Input>, typeof<'Output>, filter) Metadata = Metadata.Empty @@ -1889,10 +1889,10 @@ module SchemaDefinitions = tagsResolver : TagsResolver, deprecationReason : string): SubscriptionFieldDef<'Root, 'Input, 'Output> = upcast { Name = name - Description = Some description + Description = ValueSome description RootTypeDef = rootdef OutputTypeDef = outputdef - DeprecationReason = Some deprecationReason + DeprecationReason = ValueSome deprecationReason Args = args |> List.toArray Filter = Resolve.AsyncFilter(typeof<'Root>, typeof<'Input>, typeof<'Output>, filter) Metadata = Metadata.Empty @@ -1909,7 +1909,7 @@ module SchemaDefinitions = /// GraphQL type definition of the current input type /// If defined, this value will be used when no matching input has been provided by the requester. /// Optional input description. Usefull for generating documentation. - static member Input(name : string, typedef : #InputDef<'In>, ?defaultValue : 'In, ?description : string) : InputFieldDef = + static member Input(name : string, typedef : #InputDef<'In>, [] ?defaultValue : 'In, [] ?description : string) : InputFieldDef = upcast { InputFieldDefinition.Name = name Description = description IsSkippable = false @@ -1927,16 +1927,16 @@ module SchemaDefinitions = /// GraphQL type definition of the current input type /// If defined, this value will be used when no matching input has been provided by the requester. /// Optional input description. Usefull for generating documentation. - static member SkippableInput(name : string, typedef : #InputDef<'In>, ?description : string) : InputFieldDef = + static member SkippableInput(name : string, typedef : #InputDef<'In>, [] ?description : string) : InputFieldDef = let typedef : InputDef<'In> = upcast typedef upcast { InputFieldDefinition.Name = name - Description = description |> Option.map (fun s -> s + " Skip this field if you want to avoid saving it") + Description = description |> ValueOption.map (fun s -> s + " Skip this field if you want to avoid saving it") IsSkippable = true TypeDef = match (box typedef) with | :? NullableDef<'In> as n -> (n :> InputDef<'In option>) | _ -> Nullable typedef - DefaultValue = None + DefaultValue = ValueNone ExecuteInput = Unchecked.defaultof } /// @@ -1946,8 +1946,8 @@ module SchemaDefinitions = /// List of fields defined by the current interface. /// Optional input description. Usefull for generating documentation. /// Optional function used to resolve actual Object definition of the .NET object provided as an input. - static member Interface(name : string, fields : FieldDef<'Val> list, ?description : string, - ?resolveType : obj -> ObjectDef) : InterfaceDef<'Val> = + static member Interface(name : string, fields : FieldDef<'Val> list, [] ?description : string, + [] ?resolveType : obj -> ObjectDef) : InterfaceDef<'Val> = upcast { InterfaceDefinition.Name = name Description = description FieldsFn = fun () -> fields |> List.toArray @@ -1964,7 +1964,7 @@ module SchemaDefinitions = /// Resolves an Object definition of one of possible types, give input object. /// Optional union description. Usefull for generating documentation. static member Union(name : string, options : ObjectDef list, resolveValue : 'In -> 'Out, - ?resolveType : 'In -> ObjectDef, ?description : string) : UnionDef<'In> = + [] ?resolveType : 'In -> ObjectDef, [] ?description : string) : UnionDef<'In> = upcast { UnionDefinition.Name = name Description = description Options = options |> List.toArray @@ -1991,15 +1991,15 @@ module SchemaDefinitions = /// /// Optional function used to determine if provided .NET object instance matches current object definition. /// - static member Object(name : string, fieldsFn : unit -> FieldDef<'Val> list, ?description : string, - ?interfaces : InterfaceDef list, ?isTypeOf : obj -> bool) : ObjectDef<'Val> = + static member Object(name : string, fieldsFn : unit -> FieldDef<'Val> list, [] ?description : string, + [] ?interfaces : InterfaceDef list, [] ?isTypeOf : obj -> bool) : ObjectDef<'Val> = upcast { ObjectDefinition.Name = name Description = description FieldsFn = lazy (fieldsFn() |> List.map (fun f -> f.Name, f) |> Map.ofList) - Implements = defaultArg (Option.map List.toArray interfaces) [||] + Implements = defaultValueArg (ValueOption.map List.toArray interfaces) [||] IsTypeOf = isTypeOf } /// @@ -2012,7 +2012,7 @@ module SchemaDefinitions = /// Function which generates a list of input fields defined by the current input object. Useful, when object defines recursive dependencies. /// /// Optional input object description. Useful for generating documentation. - static member InputObject(name : string, fieldsFn : unit -> InputFieldDef list, ?description : string) : InputObjectDefinition<'Out> = + static member InputObject(name : string, fieldsFn : unit -> InputFieldDef list, [] ?description : string) : InputObjectDefinition<'Out> = { Name = name Fields = lazy (fieldsFn () |> List.toArray) Description = description @@ -2030,7 +2030,7 @@ module SchemaDefinitions = /// /// Object validator. /// Optional input object description. Useful for generating documentation. - static member InputObject(name : string, fieldsFn : unit -> InputFieldDef list, validator: GQLValidator<'Out>, ?description : string) : InputObjectDefinition<'Out> = + static member InputObject(name : string, fieldsFn : unit -> InputFieldDef list, validator: GQLValidator<'Out>, [] ?description : string) : InputObjectDefinition<'Out> = { Name = name Fields = lazy (fieldsFn () |> List.toArray) Description = description @@ -2047,8 +2047,8 @@ module SchemaDefinitions = /// /// Optional input description. Usefull for generating documentation. /// Optional function used to resolve actual Object definition of the .NET object provided as an input. - static member Interface(name : string, fieldsFn : unit -> FieldDef<'Val> list, ?description : string, - ?resolveType : obj -> ObjectDef) : InterfaceDef<'Val> = + static member Interface(name : string, fieldsFn : unit -> FieldDef<'Val> list, [] ?description : string, + [] ?resolveType : obj -> ObjectDef) : InterfaceDef<'Val> = upcast { InterfaceDefinition.Name = name Description = description FieldsFn = fun () -> fieldsFn() |> List.toArray diff --git a/src/FSharp.Data.GraphQL.Shared/TypeSystem.fs b/src/FSharp.Data.GraphQL.Shared/TypeSystem.fs index 915416223..41d174c6e 100644 --- a/src/FSharp.Data.GraphQL.Shared/TypeSystem.fs +++ b/src/FSharp.Data.GraphQL.Shared/TypeSystem.fs @@ -63,7 +63,7 @@ module Introspection = /// Directive name. Name : string /// Description of a target directive. - Description : string option + Description : string voption /// Array of AST locations, where it's valid to place target directive. Locations : DirectiveLocation[] /// Array of arguments, current directive can be parametrized with. @@ -77,22 +77,22 @@ module Introspection = /// Type name. Must be unique in scope of the defined schema. Name : string /// Optional type description. - Description : string option + Description : string voption /// Array of field descriptors defined within current type. /// Only present for Object and Interface types. - Fields : IntrospectionField[] option + Fields : IntrospectionField[] voption /// Array of interfaces implemented by output object type definition. - Interfaces : IntrospectionTypeRef[] option + Interfaces : IntrospectionTypeRef[] voption /// Array of type references being possible implementation of current type. /// Only present for Union types (list of union cases) and Interface types /// (list of all objects implementing interface in scope of the schema). - PossibleTypes : IntrospectionTypeRef[] option + PossibleTypes : IntrospectionTypeRef[] voption /// Array of enum values defined by current Enum type. - EnumValues : IntrospectionEnumVal[] option + EnumValues : IntrospectionEnumVal[] voption /// Array of input fields defined by current InputObject type. - InputFields : IntrospectionInputVal[] option + InputFields : IntrospectionInputVal[] voption /// Type param reference - used only by List and NonNull types. - OfType : IntrospectionTypeRef option + OfType : IntrospectionTypeRef voption } with /// @@ -100,16 +100,16 @@ module Introspection = /// /// Type name (unique in the scope of current schema). /// Optional type description. - static member Scalar (name : string, description : string option) = { + static member Scalar (name : string, description : string voption) = { Kind = TypeKind.SCALAR Name = name Description = description - Fields = None - Interfaces = None - PossibleTypes = None - EnumValues = None - InputFields = None - OfType = None + Fields = ValueNone + Interfaces = ValueNone + PossibleTypes = ValueNone + EnumValues = ValueNone + InputFields = ValueNone + OfType = ValueNone } /// @@ -119,16 +119,16 @@ module Introspection = /// Optional type description. /// Array of fields defined in current object. /// Array of interfaces, current object implements. - static member Object (name : string, description : string option, fields : IntrospectionField[], interfaces : IntrospectionTypeRef[]) = { + static member Object (name : string, description : string voption, fields : IntrospectionField[], interfaces : IntrospectionTypeRef[]) = { Kind = TypeKind.OBJECT Name = name Description = description - Fields = Some fields - Interfaces = Some interfaces - PossibleTypes = None - EnumValues = None - InputFields = None - OfType = None + Fields = ValueSome fields + Interfaces = ValueSome interfaces + PossibleTypes = ValueNone + EnumValues = ValueNone + InputFields = ValueNone + OfType = ValueNone } /// @@ -137,16 +137,16 @@ module Introspection = /// Type name (unique in the scope of current schema). /// Optional type description. /// Array of input fields defined in current input object. - static member InputObject (name : string, description : string option, inputFields : IntrospectionInputVal[]) = { + static member InputObject (name : string, description : string voption, inputFields : IntrospectionInputVal[]) = { Kind = TypeKind.INPUT_OBJECT Name = name Description = description - Fields = None - Interfaces = None - PossibleTypes = None - EnumValues = None - InputFields = Some inputFields - OfType = None + Fields = ValueNone + Interfaces = ValueNone + PossibleTypes = ValueNone + EnumValues = ValueNone + InputFields = ValueSome inputFields + OfType = ValueNone } /// @@ -155,16 +155,16 @@ module Introspection = /// Type name (unique in the scope of current schema). /// Optional type description. /// Array of union case types. They can be any type defined in GraphQL schema. - static member Union (name : string, description : string option, possibleTypes : IntrospectionTypeRef[]) = { + static member Union (name : string, description : string voption, possibleTypes : IntrospectionTypeRef[]) = { Kind = TypeKind.UNION Name = name Description = description - Fields = None - Interfaces = None - PossibleTypes = Some possibleTypes - EnumValues = None - InputFields = None - OfType = None + Fields = ValueNone + Interfaces = ValueNone + PossibleTypes = ValueSome possibleTypes + EnumValues = ValueNone + InputFields = ValueNone + OfType = ValueNone } /// @@ -173,16 +173,16 @@ module Introspection = /// Type name (unique in the scope of current schema). /// Optional type description. /// Array of enum value descriptors. - static member Enum (name : string, description : string option, enumValues : IntrospectionEnumVal[]) = { + static member Enum (name : string, description : string voption, enumValues : IntrospectionEnumVal[]) = { Kind = TypeKind.ENUM Name = name Description = description - Fields = None - Interfaces = None - PossibleTypes = None - EnumValues = Some enumValues - InputFields = None - OfType = None + Fields = ValueNone + Interfaces = ValueNone + PossibleTypes = ValueNone + EnumValues = ValueSome enumValues + InputFields = ValueNone + OfType = ValueNone } /// @@ -192,16 +192,16 @@ module Introspection = /// Optional type description. /// Array of fields being part of the interface contract. /// Array of schema objects implementing target interface. - static member Interface (name : string, description : string option, fields : IntrospectionField[], possibleTypes : IntrospectionTypeRef[]) = { + static member Interface (name : string, description : string voption, fields : IntrospectionField[], possibleTypes : IntrospectionTypeRef[]) = { Kind = TypeKind.INTERFACE Name = name Description = description - Fields = Some fields - Interfaces = None - PossibleTypes = Some possibleTypes - EnumValues = None - InputFields = None - OfType = None + Fields = ValueSome fields + Interfaces = ValueNone + PossibleTypes = ValueSome possibleTypes + EnumValues = ValueNone + InputFields = ValueNone + OfType = ValueNone } /// Introspection type reference. Used to navigate between type dependencies inside introspected schema. @@ -209,18 +209,23 @@ module Introspection = /// Referenced type kind. Kind : TypeKind /// Type name. None if referenced type is List or NonNull. - Name : string option + Name : string voption /// Optional type description. - Description : string option + Description : string voption /// Type param reference. Used only by List and NonNull types. - OfType : IntrospectionTypeRef option + OfType : IntrospectionTypeRef voption } with /// /// Constructs an introspection type reference for List types. /// /// Type reference for type used as List's type param. - static member List (inner : IntrospectionTypeRef) = { Kind = TypeKind.LIST; Name = None; Description = None; OfType = Some inner } + static member List (inner : IntrospectionTypeRef) = { + Kind = TypeKind.LIST + Name = ValueNone + Description = ValueNone + OfType = ValueSome inner + } /// /// Constructs an introspection type reference for NonNull types. @@ -228,9 +233,9 @@ module Introspection = /// Type reference for type used as NonNull's type param. static member NonNull (inner : IntrospectionTypeRef) = { Kind = TypeKind.NON_NULL - Name = None - Description = None - OfType = Some inner + Name = ValueNone + Description = ValueNone + OfType = ValueSome inner } /// @@ -240,9 +245,9 @@ module Introspection = /// Introspection type descriptor to construct reference from. static member Named (inner : IntrospectionType) = { Kind = inner.Kind - Name = Some inner.Name + Name = ValueSome inner.Name Description = inner.Description - OfType = None + OfType = ValueNone } /// Introspection descriptor for input values (InputObject fields or field arguments). @@ -250,11 +255,11 @@ module Introspection = /// Input argument name. Name : string /// Optional input argument description. - Description : string option + Description : string voption /// Introspection reference to argument's type. Type : IntrospectionTypeRef /// Default arguments value, if provided. - DefaultValue : string option + DefaultValue : string voption } /// Introspection descriptor for enum values. @@ -262,12 +267,12 @@ module Introspection = /// Enum value name - must be unique in scope of defining enum. Name : string /// Optional enum value description. - Description : string option + Description : string voption /// If true, marks current value as deprecated, but still /// available for compatibility reasons. IsDeprecated : bool /// If value is deprecated this field may describe a deprecation reason. - DeprecationReason : string option + DeprecationReason : string voption } /// Introspection descriptor for Object and Interface fields. @@ -275,7 +280,7 @@ module Introspection = /// Field name. Must be unique in scope of the definin object/interface. Name : string /// Optional field description. - Description : string option + Description : string voption /// Array of field arguments. In GraphQL fields can be parametrized, /// working effectively like methods. Args : IntrospectionInputVal[] @@ -285,7 +290,7 @@ module Introspection = /// available for compatibility reasons. IsDeprecated : bool /// If field is deprecated here a deprecation reason may be set. - DeprecationReason : string option + DeprecationReason : string voption } /// Introspection descriptor for target schema. Contains informations about @@ -294,9 +299,9 @@ module Introspection = /// Introspection reference to schema's query root. QueryType : IntrospectionTypeRef /// Introspection reference to schema's mutation root. - MutationType : IntrospectionTypeRef option + MutationType : IntrospectionTypeRef voption /// Introspection reference to schema's subscription root. - SubscriptionType : IntrospectionTypeRef option + SubscriptionType : IntrospectionTypeRef voption /// Array of all introspection types defined within current schema. /// Includes types for queries, mutations and subscriptions. Types : IntrospectionType array @@ -1020,9 +1025,9 @@ and FieldDef = /// Name of the field. abstract Name : string /// Optional field description. - abstract Description : string option + abstract Description : string voption /// Optional field deprecation warning. - abstract DeprecationReason : string option + abstract DeprecationReason : string voption /// Field's GraphQL type definition. abstract TypeDef : OutputDef /// Field's arguments list. @@ -1052,7 +1057,7 @@ and [] internal FieldDefinition<'Val, 'Res> = { /// Name of the field. Name : string /// Optional field description. - Description : string option + Description : string voption /// Field's GraphQL type definition. TypeDef : OutputDef<'Res> /// Field resolution function. @@ -1060,7 +1065,7 @@ and [] internal FieldDefinition<'Val, 'Res> = /// Field's arguments list. Args : InputFieldDef [] /// Optional field deprecation warning. - DeprecationReason : string option + DeprecationReason : string voption /// Field metadata definition. Metadata : Metadata } @@ -1112,7 +1117,7 @@ and ScalarDef = /// Name of the scalar type. abstract Name : string /// Optional scalar type description. - abstract Description : string option + abstract Description : string voption /// A function used to retrieve a .NET object from provided GraphQL query or JsonElement variable. abstract CoerceInput : InputParameterValue -> Result /// A function used to serialize a .NET object and coerce its value to JSON compatible if needed. @@ -1128,7 +1133,7 @@ and [] ScalarDefinition<'Primitive, 'Val> = { /// Name of the scalar type. Name : string /// Optional type description. - Description : string option + Description : string voption /// A function used to retrieve a .NET object from provided GraphQL query or JsonElement variable. CoerceInput : InputParameterValue -> Result<'Val, IGQLError list> /// A function used to set a surrogate representation to be @@ -1180,7 +1185,7 @@ and FileDef = /// Name of the file type. abstract Name : string /// Optional scalar type description. - abstract Description : string option + abstract Description : string voption /// A function used to retrieve a .NET object from provided GraphQL query or JsonElement variable. abstract Coerce : IInputExecutionContext -> InputParameterValue -> Result inherit TypeDef @@ -1195,11 +1200,11 @@ and EnumVal = /// Identifier of the enum value. abstract Name : string /// Optional enum value description. - abstract Description : string option + abstract Description : string voption /// Value to be stringified as a result to the user. abstract Value : obj /// Optional description of the deprecation reason. - abstract DeprecationReason : string option + abstract DeprecationReason : string voption end /// A GraphQL representation of a single case of the enum type. @@ -1210,9 +1215,9 @@ and EnumValue<'Val> = { /// Value to be stringified as a result to the user. Value : 'Val /// Optional enum value description. - Description : string option + Description : string voption /// Optional description of the deprecation reason. - DeprecationReason : string option + DeprecationReason : string voption } with interface EnumVal with @@ -1231,7 +1236,7 @@ and EnumDef = /// Enum type name. abstract Name : string /// Optional enum type description. - abstract Description : string option + abstract Description : string voption /// List of available enum cases. abstract Options : EnumVal[] inherit TypeDef @@ -1256,7 +1261,7 @@ and internal EnumDefinition<'Val> = { /// Enum type name. Name : string /// Optional enum type description. - Description : string option + Description : string voption /// List of available enum cases. Options : EnumValue<'Val>[] } with @@ -1297,14 +1302,14 @@ and ObjectDef = /// Name of the object type definition. abstract Name : string /// Optional object definition description. - abstract Description : string option + abstract Description : string voption /// Collection of fields defined by the current object. abstract Fields : Map /// Collection of interfaces implemented by the current object. abstract Implements : InterfaceDef[] /// Optional function used to recognize of provided /// .NET object is valid for this GraphQL object definition. - abstract IsTypeOf : (obj -> bool) option + abstract IsTypeOf : (obj -> bool) voption inherit TypeDef inherit NamedDef inherit OutputDef @@ -1327,7 +1332,7 @@ and [] internal ObjectDefinition<'Val> = { /// Name of the object type definition. Name : string /// Optional object definition description. - Description : string option + Description : string voption /// Lazy resolver for the object fields. It must be lazy in /// order to allow self-recursive type references. FieldsFn : Lazy>> @@ -1335,7 +1340,7 @@ and [] internal ObjectDefinition<'Val> = { Implements : InterfaceDef[] /// Optional function used to recognize of provided /// .NET object is valid for this GraphQL object definition. - IsTypeOf : (obj -> bool) option + IsTypeOf : (obj -> bool) voption } with interface TypeDef with @@ -1382,14 +1387,14 @@ and InterfaceDef = /// Name of the interface type definition. abstract Name : string /// Optional interface description. - abstract Description : string option + abstract Description : string voption /// List of fields to be defined by implementing object /// definition in order to satisfy current interface. abstract Fields : FieldDef[] /// Optional funciton used to determine, which object /// definition is a concrete implementation of the current /// interface for provided .NET object. - abstract ResolveType : (obj -> ObjectDef) option + abstract ResolveType : (obj -> ObjectDef) voption inherit TypeDef inherit OutputDef inherit CompositeDef @@ -1413,7 +1418,7 @@ and [] internal InterfaceDefinition<'Val> = { /// Name of the interface type definition. Name : string /// Optional interface description. - Description : string option + Description : string voption /// Lazy definition of fields to be defined by implementing /// object definition in order to satisfy current interface. /// Must be lazy in order to allow self-referencing types. @@ -1421,7 +1426,7 @@ and [] internal InterfaceDefinition<'Val> = { /// Optional funciton used to determine, which object /// definition is a concrete implementation of the current /// interface for provided .NET object. - ResolveType : (obj -> ObjectDef) option + ResolveType : (obj -> ObjectDef) voption } with interface TypeDef with @@ -1467,13 +1472,13 @@ and UnionDef = /// Name of the union type definition. abstract Name : string /// Optiona union type description. - abstract Description : string option + abstract Description : string voption /// Collection of object cases represented by this union. abstract Options : ObjectDef[] /// Optional funciton used to determine, which object /// definition is a concrete implementation of the current /// union for provided .NET object. - abstract ResolveType : (obj -> ObjectDef) option + abstract ResolveType : (obj -> ObjectDef) voption /// Helper function which provides ability to retrieve /// specific values, that are wrapped in F# discriminated unions. abstract ResolveValue : obj -> obj @@ -1491,7 +1496,7 @@ and UnionDef<'In> = /// Optional funciton used to determine, which object /// definition is a concrete implementation of the current /// union for provided .NET object. - abstract ResolveType : ('In -> ObjectDef) option + abstract ResolveType : ('In -> ObjectDef) voption /// Helper function which provides ability to retrieve /// specific values, that are wrapped in F# discriminated unions. abstract ResolveValue : 'In -> obj @@ -1505,13 +1510,13 @@ and [] internal UnionDefinition<'In, 'Out> = { /// Name of the union type definition. Name : string /// Optiona union type description. - Description : string option + Description : string voption /// Collection of object cases represented by this union. Options : ObjectDef[] /// Optional funciton used to determine, which object /// definition is a concrete implementation of the current /// union for provided .NET object. - ResolveType : ('In -> ObjectDef) option + ResolveType : ('In -> ObjectDef) voption /// Helper function which provides ability to retrieve /// specific values, that are wrapped in F# discriminated unions. ResolveValue : 'In -> 'Out @@ -1536,7 +1541,7 @@ and [] internal UnionDefinition<'In, 'Out> = { member x.Options = x.Options member x.ResolveType = x.ResolveType - |> Option.map (fun fn -> (fun value -> fn (value :?> 'In))) + |> ValueOption.map (fun fn -> (fun value -> fn (value :?> 'In))) member x.ResolveValue value = upcast x.ResolveValue (value :?> 'In) interface UnionDef<'In> with @@ -1702,7 +1707,7 @@ and InputObjectDef = /// Name of the input object. abstract Name : string /// Optional input object description. - abstract Description : string option + abstract Description : string voption /// Collection of input object fields. abstract Fields : InputFieldDef[] /// Validates if input object has a a valid combination of filed values. @@ -1720,7 +1725,7 @@ and InputObjectDefinition<'Val> = { /// Name of the input object. Name : string /// Optional input object description. - Description : string option + Description : string voption /// Lazy resolver for the input object fields. It must be lazy in /// order to allow self-recursive type references. Fields : Lazy @@ -1771,13 +1776,13 @@ and InputFieldDef = /// Name of the input field / argument. abstract Name : string /// Optional input field / argument description. - abstract Description : string option + abstract Description : string voption /// Not applied to input object if field is missing but does not allow null. abstract IsSkippable : bool /// GraphQL type definition of the input type. abstract TypeDef : InputDef /// Optional default input value - used when no input was provided. - abstract DefaultValue : obj option + abstract DefaultValue : obj voption /// INTERNAL API: input execution function - /// compiled by the runtime. abstract ExecuteInput : ExecuteInput with get, set @@ -1790,13 +1795,13 @@ and [] InputFieldDefinition<'In> = { /// Name of the input field / argument. Name : string /// Optional input field / argument description. - Description : string option + Description : string voption /// Not applied to input object if field is missing but does not allow null. IsSkippable : bool /// GraphQL type definition of the input type. TypeDef : InputDef<'In> /// Optional default input value - used when no input was provided. - DefaultValue : 'In option + DefaultValue : 'In voption /// INTERNAL API: input execution function - /// compiled by the runtime. mutable ExecuteInput : ExecuteInput @@ -1807,7 +1812,7 @@ and [] InputFieldDefinition<'In> = { member x.Description = x.Description member x.IsSkippable = x.IsSkippable member x.TypeDef = upcast x.TypeDef - member x.DefaultValue = x.DefaultValue |> Option.map (fun x -> upcast x) + member x.DefaultValue = x.DefaultValue |> ValueOption.map (fun x -> upcast x) member x.ExecuteInput with get () = x.ExecuteInput @@ -1833,7 +1838,7 @@ and internal InputCustomDef = /// Name of the input field / argument. abstract Name : string /// Optional input field / argument description. - abstract Description : string option + abstract Description : string voption /// A function used to retrieve a .NET object from provided GraphQL query or JsonElement variable. abstract CoerceInput : InputExecutionContextProvider -> InputParameterValue -> Variables -> Result inherit TypeDef @@ -1844,7 +1849,7 @@ and internal InputCustomDef = and InputCustomDefinition<'Val> = internal { Name : string - Description : string option + Description : string voption CoerceInput : InputExecutionContextProvider -> InputParameterValue -> Variables -> Result<'Val, IGQLError list> } with interface TypeDef with @@ -1902,8 +1907,8 @@ and SubscriptionFieldDef<'Root, 'Input, 'Output> = and [] SubscriptionFieldDefinition<'Root, 'Input, 'Output> = { Name : string - Description : string option - DeprecationReason : string option + Description : string voption + DeprecationReason : string voption // The type of the value that the subscription consumes, used to make sure that our filter function is properly typed OutputTypeDef : OutputDef<'Output> // The type of the root value, we need to thread this into our filter function @@ -1970,7 +1975,7 @@ and SubscriptionObjectDef<'Val> = and [] SubscriptionObjectDefinition<'Val> = { Name : string - Description : string option + Description : string voption Fields : Map> } with @@ -1990,7 +1995,7 @@ and [] SubscriptionObjectDefinition<'Val> = { member x.Fields = x.Fields |> Map.map (fun _ f -> f :> FieldDef) member x.Implements = Array.empty : InterfaceDef[] // TODO: Actually add istypeof - member x.IsTypeOf = None + member x.IsTypeOf = ValueNone interface ObjectDef<'Val> with member x.Fields = x.Fields |> Map.map (fun _ f -> f :> FieldDef<'Val>) @@ -2016,7 +2021,7 @@ and DirectiveDef = { /// Directive's name - it's NOT '@' prefixed. Name : string /// Optional directive description. - Description : string option + Description : string voption /// Directive location - describes, which part's of the query AST /// are valid places to include current directive to. Locations : DirectiveLocation diff --git a/src/FSharp.Data.GraphQL.Shared/Validation.fs b/src/FSharp.Data.GraphQL.Shared/Validation.fs index a0d45ef1c..c364fdddb 100644 --- a/src/FSharp.Data.GraphQL.Shared/Validation.fs +++ b/src/FSharp.Data.GraphQL.Shared/Validation.fs @@ -160,13 +160,15 @@ module Ast = match tref.Kind with | TypeKind.NON_NULL | TypeKind.LIST when tref.OfType.IsSome -> tryGetSchemaTypeByRef schemaTypes tref.OfType.Value - | _ -> tref.Name |> Option.bind schemaTypes.TryFind + | _ -> + tref.Name + |> ValueOption.bind (schemaTypes.TryFind >> ValueOption.ofOption) type SchemaInfo = { SchemaTypes : Map - QueryType : IntrospectionType option - SubscriptionType : IntrospectionType option - MutationType : IntrospectionType option + QueryType : IntrospectionType voption + SubscriptionType : IntrospectionType voption + MutationType : IntrospectionType voption Directives : IntrospectionDirective[] } with @@ -178,10 +180,10 @@ module Ast = QueryType = tryGetSchemaTypeByRef schemaTypes schema.QueryType MutationType = schema.MutationType - |> Option.bind (tryGetSchemaTypeByRef schemaTypes) + |> ValueOption.bind (tryGetSchemaTypeByRef schemaTypes) SubscriptionType = schema.SubscriptionType - |> Option.bind (tryGetSchemaTypeByRef schemaTypes) + |> ValueOption.bind (tryGetSchemaTypeByRef schemaTypes) Directives = schema.Directives } member x.TryGetOperationType (ot : OperationType) = @@ -333,9 +335,7 @@ module Ast = |> ValueOption.map _.TypeCondition |> ValueOption.defaultValue x.ParentType - let private tryFindInArrayOption (finder : 'T -> bool) = - ValueOption.ofOption - >> ValueOption.bind (Array.tryFind finder >> ValueOption.ofOption) + let private tryFindInArrayOption (finder : 'T -> bool) = ValueOption.bind (Array.tryFind finder >> ValueOption.ofOption) let private onAllSelections (ctx : ValidationContext) (onSelection : SelectionInfo -> ValidationResult) = let rec traverseSelections selection = @@ -540,8 +540,8 @@ module Ast = else let exists = selection.FragmentOrParentType.Fields - |> Option.map (Array.exists (fun f -> f.Name = selection.Field.Name)) - |> Option.defaultValue false + |> ValueOption.map (Array.exists (fun f -> f.Name = selection.Field.Name)) + |> ValueOption.defaultValue false if not exists then AstError.AsResult ( $"Field '%s{selection.Field.Name}' is not defined in schema type '%s{selection.FragmentOrParentType.Name}'.", @@ -553,14 +553,14 @@ module Ast = let private typesAreApplicable (parentType : IntrospectionType, fragmentType : IntrospectionType) = let parentPossibleTypes = parentType.PossibleTypes - |> Option.defaultValue [||] - |> Seq.choose _.Name + |> ValueOption.defaultValue [||] + |> Seq.vchoose _.Name |> Seq.append (Seq.singleton parentType.Name) |> Set.ofSeq let fragmentPossibleTypes = fragmentType.PossibleTypes - |> Option.defaultValue [||] - |> Seq.choose _.Name + |> ValueOption.defaultValue [||] + |> Seq.vchoose _.Name |> Seq.append (Seq.singleton fragmentType.Name) |> Set.ofSeq let applicableTypes = Set.intersect parentPossibleTypes fragmentPossibleTypes @@ -978,21 +978,21 @@ module Ast = | _ when tref.Kind = TypeKind.NON_NULL -> checkIsCoercible tref.OfType.Value argName value | IntValue _ -> match tref.Name, tref.Kind with - | Some ("ID" | "Int" | "Long" | "Float"), TypeKind.SCALAR -> Success + | ValueSome ("ID" | "Int" | "Long" | "Float"), TypeKind.SCALAR -> Success | _ -> canNotCoerce | FloatValue _ -> match tref.Name, tref.Kind with - | Some "Float", TypeKind.SCALAR -> Success + | ValueSome "Float", TypeKind.SCALAR -> Success | _ -> canNotCoerce | BooleanValue _ -> match tref.Name, tref.Kind with - | Some "Boolean", TypeKind.SCALAR -> Success + | ValueSome "Boolean", TypeKind.SCALAR -> Success | _ -> canNotCoerce | StringValue _ -> let invalidScalars = [| "Int"; "Float"; "Boolean" |] match tref.Name, tref.Kind with - | (Some x, TypeKind.SCALAR) when not (Array.contains x invalidScalars) -> Success - | (Some x, TypeKind.INPUT_OBJECT) when x = FileType.Name -> Success + | (ValueSome x, TypeKind.SCALAR) when not (Array.contains x invalidScalars) -> Success + | (ValueSome x, TypeKind.INPUT_OBJECT) when x = FileType.Name -> Success | _ -> canNotCoerce | EnumValue _ -> match tref.Kind with @@ -1011,10 +1011,10 @@ module Ast = | TypeKind.UNION | TypeKind.INPUT_OBJECT when tref.Name.IsSome -> match schemaInfo.TryGetTypeByRef (tref) with - | Some itype -> + | ValueSome itype -> let fieldMap = itype.InputFields - |> Option.defaultValue [||] + |> ValueOption.defaultValue [||] |> Array.fold (fun acc inputVal -> Map.add inputVal.Name inputVal.Type acc) Map.empty let canCoerceFields = fieldMap @@ -1040,7 +1040,7 @@ module Ast = selection.Path )) canCoerceFields @@ canCoerceProps - | None -> canNotCoerce + | ValueNone -> canNotCoerce | _ -> canNotCoerce | VariableName varName -> let variableDefinition = diff --git a/tests/FSharp.Data.GraphQL.Tests/AstValidationTests.fs b/tests/FSharp.Data.GraphQL.Tests/AstValidationTests.fs index a5dd095cf..033b45315 100644 --- a/tests/FSharp.Data.GraphQL.Tests/AstValidationTests.fs +++ b/tests/FSharp.Data.GraphQL.Tests/AstValidationTests.fs @@ -293,12 +293,12 @@ let Subscription = let directives = [ - { Name = "queryOnly" ; Description = None ; Locations = DirectiveLocation.QUERY ; Args = [||] } - { Name = "mutationOnly" ; Description = None ; Locations = DirectiveLocation.MUTATION ; Args = [||] } - { Name = "subscriptionOnly" ; Description = None ; Locations = DirectiveLocation.SUBSCRIPTION ; Args = [||] } - { Name = "fragSpreadOnly" ; Description = None ; Locations = DirectiveLocation.FRAGMENT_SPREAD ; Args = [||] } - { Name = "inlineFragOnly" ; Description = None ; Locations = DirectiveLocation.INLINE_FRAGMENT ; Args = [||] } - { Name = "fieldOnly" ; Description = None ; Locations = DirectiveLocation.FIELD ; Args = [||] } + { Name = "queryOnly" ; Description = ValueNone ; Locations = DirectiveLocation.QUERY ; Args = [||] } + { Name = "mutationOnly" ; Description = ValueNone ; Locations = DirectiveLocation.MUTATION ; Args = [||] } + { Name = "subscriptionOnly" ; Description = ValueNone ; Locations = DirectiveLocation.SUBSCRIPTION ; Args = [||] } + { Name = "fragSpreadOnly" ; Description = ValueNone ; Locations = DirectiveLocation.FRAGMENT_SPREAD ; Args = [||] } + { Name = "inlineFragOnly" ; Description = ValueNone ; Locations = DirectiveLocation.INLINE_FRAGMENT ; Args = [||] } + { Name = "fieldOnly" ; Description = ValueNone ; Locations = DirectiveLocation.FIELD ; Args = [||] } ] |> List.append SchemaConfig.Default.Directives diff --git a/tests/FSharp.Data.GraphQL.Tests/Variables and Inputs/OptionalsNormalizationTests.ValidString.fs b/tests/FSharp.Data.GraphQL.Tests/Variables and Inputs/OptionalsNormalizationTests.ValidString.fs index 194c266d6..297d29275 100644 --- a/tests/FSharp.Data.GraphQL.Tests/Variables and Inputs/OptionalsNormalizationTests.ValidString.fs +++ b/tests/FSharp.Data.GraphQL.Tests/Variables and Inputs/OptionalsNormalizationTests.ValidString.fs @@ -148,7 +148,7 @@ module Scalars = type Define with static member ValidStringScalar<'t> - (typeName, createValid : Validator, toString : 't -> string, ?description : string) + (typeName, createValid : Validator, toString : 't -> string, [] ?description : string) = let createValid : string -> ValidationResult<'t> = createValid typeName Define.WrappedScalar ( @@ -173,7 +173,7 @@ module Scalars = ?description = description ) - static member ValidStringScalar<'t>(typeName, createValid : Validator, toString : 't -> string, ?description: string) = + static member ValidStringScalar<'t>(typeName, createValid : Validator, toString : 't -> string, [] ?description: string) = let createValid = createValid typeName Define.WrappedScalar (name = typeName,