Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions samples/relay-book-store/Schema.fs
Original file line number Diff line number Diff line change
Expand Up @@ -159,14 +159,14 @@ let booksField =
let startCursor = async {
let! edges = edges

return edges |> Seq.tryHead |> Option.map (fun x -> x.Cursor)
return edges |> Seq.tryHead |> Option.map _.Cursor
}

// The cursor of the last edge
let endCursor = async {
let! edges = edges

return edges |> Seq.tryLast |> Option.map (fun x -> x.Cursor)
return edges |> Seq.tryLast |> Option.map _.Cursor
}

{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ type GraphQLTypeProvider (config) as this =
if args.Name.Contains("FSharp.Data.GraphQL") then
printfn "ResolveAssembly: %s" args.Name
config.ReferencedAssemblies
|> Array.filter(fun x -> x.Contains("FSharp.Data"))
|> Array.iter (fun x -> printfn "%s" x)
|> Array.filter _.Contains("FSharp.Data")
|> Array.iter (fun x -> printfn "%s" x)
base.ResolveAssembly args

[<assembly:TypeProviderAssembly>]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ module internal ProvidedRecord =
|> List.partition (fun (_, t) -> isOption t)
if explicitOptionalParameters then
let constructorProperties = requiredProperties @ optionalProperties
let propertyNames = constructorProperties |> List.map (fst >> (fun x -> x.FirstCharUpper()))
let propertyNames = constructorProperties |> List.map (fst >> _.FirstCharUpper())
let constructorPropertyTypes = constructorProperties |> List.map snd
let invoker (args : Expr list) =
let properties =
Expand All @@ -208,7 +208,7 @@ module internal ProvidedRecord =
List.combinations optionalProperties
|> List.map (fun (optionalProperties, nullValuedProperties) ->
let constructorProperties = requiredProperties @ optionalProperties
let propertyNames = (constructorProperties @ nullValuedProperties) |> List.map (fst >> (fun x -> x.FirstCharUpper()))
let propertyNames = (constructorProperties @ nullValuedProperties) |> List.map (fst >> _.FirstCharUpper())
let constructorPropertyTypes = constructorProperties |> List.map snd
let nullValuedPropertyTypes = nullValuedProperties |> List.map snd
let invoker (args : Expr list) =
Expand Down Expand Up @@ -545,7 +545,7 @@ module internal Provider =
|> List.choose (function FragmentField f when f.TypeCondition <> tref.Name.Value -> Some f | _ -> None)
|> List.groupBy (fun field -> field.TypeCondition)
|> List.map (fun (typeCondition, fields) ->
let conditionFields = fields |> List.distinctBy (fun x -> x.AliasOrName) |> List.map FragmentField
let conditionFields = fields |> Seq.distinctBy _.AliasOrName |> Seq.map FragmentField |> Seq.toList
typeCondition, List.map (getPropertyMetadata typeCondition) conditionFields)
let baseProperties =
astFields
Expand All @@ -554,7 +554,7 @@ module internal Provider =
| TypeField _ -> Some x
| FragmentField f when f.TypeCondition = tref.Name.Value -> Some x
| _ -> None)
|> List.distinctBy (fun x -> x.AliasOrName)
|> List.distinctBy _.AliasOrName
|> List.map (getPropertyMetadata tref.Name.Value)
let baseType =
let metadata : ProvidedTypeMetadata = { Name = tref.Name.Value; Description = tref.Description }
Expand Down
2 changes: 1 addition & 1 deletion src/FSharp.Data.GraphQL.Client/BaseTypes.fs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ type RecordBase (name : string, properties : RecordProperty seq) =

let properties =
if not (isNull properties)
then properties |> Seq.sortBy (fun x -> x.Name) |> List.ofSeq
then properties |> Seq.sortBy _.Name |> List.ofSeq
else []

/// Gets the name of this provided record type.
Expand Down
2 changes: 1 addition & 1 deletion src/FSharp.Data.GraphQL.Client/Extensions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module internal Extensions =
member this.MD5Hash() =
Encoding.UTF8.GetBytes(this)
|> MD5.Create().ComputeHash
|> Array.map (fun x -> x.ToString("x2"))
|> Array.map _.ToString("x2")
|> Array.reduce (+)

/// Basic operations on lists.
Expand Down
2 changes: 1 addition & 1 deletion src/FSharp.Data.GraphQL.Server/Execution.fs
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ and private live (inputContext : InputExecutionContextProvider) (ctx : ResolveFi
|> Observable.mergeInner

let provider = ctx.Schema.LiveFieldSubscriptionProvider
let filter = provider.TryFind typeName name |> Option.map (fun x -> x.Filter)
let filter = provider.TryFind typeName name |> Option.map _.Filter
let updates =
match filter with
| Some filterFn -> provider.Add (filterFn parent) typeName name |> Observable.bind resolveUpdate
Expand Down
2 changes: 1 addition & 1 deletion src/FSharp.Data.GraphQL.Server/Executor.fs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ type Executor<'Root>(schema: ISchema<'Root>, middlewares : IExecutorMiddleware s
Metadata = meta
Operation = operation
DocumentId = documentId }
return runMiddlewares (fun x -> x.PlanOperation) planningCtx planOperation
return runMiddlewares _.PlanOperation planningCtx planOperation
| None -> return! Error <| [ GQLProblemDetails.CreateWithKind (
"No operation with specified name has been found for provided document",
ErrorKind.Validation
Expand Down
2 changes: 1 addition & 1 deletion src/FSharp.Data.GraphQL.Server/Values.fs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ let rec internal compileByType
| InputCustom customDef -> fun inputContext value variables -> customDef.CoerceInput inputContext (InlineConstant value) variables
| InputObject objDef ->
let objType = objDef.Type
let ctor = ReflectionHelper.matchConstructor objType (objDef.Fields |> Array.map (fun x -> x.Name))
let ctor = ReflectionHelper.matchConstructor objType (objDef.Fields |> Array.map _.Name)

let parametersMap =
let typeMismatchParameters = HashSet ()
Expand Down
47 changes: 24 additions & 23 deletions src/FSharp.Data.GraphQL.Shared/Validation.fs
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,13 @@ module Ast =
type MetaTypeFieldInfo = { Name : string; ArgumentNames : string[] }

let private metaTypeFields =
[|
seq {
{ Name = "__type"; ArgumentNames = [| "name" |] }
{ Name = "__schema"; ArgumentNames = [||] }
{ Name = "__typename"; ArgumentNames = [||] }
|]
|> Array.map (fun x -> x.Name, x)
|> Map.ofArray
}
|> Seq.map (fun x -> x.Name, x)
|> Map.ofSeq

let rec private tryGetSchemaTypeByRef (schemaTypes : Map<string, IntrospectionType>) (tref : IntrospectionTypeRef) =
match tref.Kind with
Expand Down Expand Up @@ -436,8 +436,8 @@ module Ast =
AstError.AsResult $"Operation '%s{name}' has %i{count} definitions. Each operation name must be unique.")

let internal validateLoneAnonymousOperation (ctx : ValidationContext) =
let operations = ctx.OperationDefinitions |> List.map (fun x -> x.Definition)
let unamed = operations |> List.filter (fun x -> x.Name.IsNone)
let operations = ctx.OperationDefinitions |> List.map _.Definition
let unamed = operations |> List.filter _.Name.IsNone
if unamed.Length = 0 then
Success
elif unamed.Length = 1 && operations.Length = 1 then
Expand Down Expand Up @@ -529,7 +529,7 @@ module Ast =
)

let rec private fieldsInSetCanMerge (set : SelectionInfo list) =
let fieldsForName = set |> List.groupBy (fun x -> x.AliasOrName)
let fieldsForName = set |> List.groupBy _.AliasOrName
fieldsForName
|> ValidationResult.collect (fun (aliasOrName, selectionSet) ->
if selectionSet.Length < 2 then
Expand Down Expand Up @@ -596,8 +596,9 @@ module Ast =
|> ValidationResult.collect (fun arg ->
let schemaArgumentNames =
metaTypeFields.TryFind (selection.Field.Name)
|> Option.map (fun x -> x.ArgumentNames)
|> Option.defaultValue (selection.InputValues |> Array.map (fun x -> x.Name))
|> ValueOption.ofOption
|> ValueOption.map _.ArgumentNames
|> ValueOption.defaultWith (fun () -> selection.InputValues |> Array.map _.Name)
match schemaArgumentNames |> Array.tryFind (fun x -> x = arg.Name) with
| Some _ -> Success
| None ->
Expand Down Expand Up @@ -633,7 +634,7 @@ module Ast =
let rec private validateArgumentUniquenessInSelection (selection : SelectionInfo) =
let validateArgs (fieldOrDirective : string) (path : FieldPath) (args : Argument list) =
args
|> List.countBy (fun x -> x.Name)
|> List.countBy _.Name
|> ValidationResult.collect (fun (name, length) ->
if length > 1 then
AstError.AsResult (
Expand Down Expand Up @@ -1019,7 +1020,7 @@ module Ast =
match selection with
| Field field ->
let path = box field.AliasOrName :: path
let fieldDirectives = [ path, field.Directives |> List.map (fun x -> x.Name) |> Set.ofList ]
let fieldDirectives = [ path, field.Directives |> Seq.map _.Name |> Set.ofSeq ]
let selectionSetDirectives =
field.SelectionSet
|> List.collect (getDistinctDirectiveNamesInSelection path)
Expand All @@ -1028,12 +1029,12 @@ module Ast =
| FragmentSpread spread -> [
path,
spread.Directives
|> List.map (fun x -> x.Name)
|> Set.ofList
|> Seq.map _.Name
|> Set.ofSeq
]

and private getDistinctDirectiveNamesInDefinition (path : FieldPath) (frag : Definition) : (FieldPath * Set<string>) list =
let fragDirectives = [ path, frag.Directives |> List.map (fun x -> x.Name) |> Set.ofList ]
let fragDirectives = [ path, frag.Directives |> Seq.map _.Name |> Set.ofSeq ]
let selectionSetDirectives =
frag.SelectionSet
|> List.collect (getDistinctDirectiveNamesInSelection path)
Expand Down Expand Up @@ -1172,7 +1173,7 @@ module Ast =
directivesValid @@ directivesValidInSelectionSet

let internal validateDirectivesAreInValidLocations (ctx : ValidationContext) =
let fragmentDefinitions = ctx.FragmentDefinitions |> List.map (fun x -> x.Definition)
let fragmentDefinitions = ctx.FragmentDefinitions |> List.map _.Definition
ctx.Document.Definitions
|> ValidationResult.collect (fun def ->
let path = def.Name |> ValueOption.map box |> ValueOption.toList
Expand All @@ -1194,16 +1195,16 @@ module Ast =
match selection with
| Field field ->
let path = box field.AliasOrName :: path
let fieldDirectives = [ path, field.Directives |> List.map (fun x -> x.Name) ]
let fieldDirectives = [ path, field.Directives |> List.map _.Name ]
let selectionSetDirectives =
field.SelectionSet
|> List.collect (getDirectiveNamesInSelection path)
fieldDirectives |> List.append selectionSetDirectives
| InlineFragment frag -> getDirectiveNamesInDefinition path (FragmentDefinition frag)
| FragmentSpread spread -> [ path, spread.Directives |> List.map (fun x -> x.Name) ]
| FragmentSpread spread -> [ path, spread.Directives |> List.map _.Name ]

and private getDirectiveNamesInDefinition (path : FieldPath) (frag : Definition) : (FieldPath * string list) list =
let fragDirectives = [ path, frag.Directives |> List.map (fun x -> x.Name) ]
let fragDirectives = [ path, frag.Directives |> List.map _.Name ]
let selectionSetDirectives =
frag.SelectionSet
|> List.collect (getDirectiveNamesInSelection path)
Expand All @@ -1216,14 +1217,14 @@ module Ast =
match def.Name with
| ValueSome name -> [ box name ]
| ValueNone -> []
let defDirectives = path, def.Directives |> List.map (fun x -> x.Name)
let defDirectives = path, def.Directives |> List.map _.Name
let selectionSetDirectives =
def.Definition.SelectionSet
|> List.collect (getDirectiveNamesInSelection path)
defDirectives :: selectionSetDirectives)
|> ValidationResult.collect (fun (path, directives) ->
directives
|> List.countBy id
|> Seq.countBy id
|> ValidationResult.collect (fun (name, count) ->
if count <= 1 then
Success
Expand Down Expand Up @@ -1324,8 +1325,8 @@ module Ast =
let path = def.Name |> ValueOption.map box |> ValueOption.toList
let varNames =
def.VariableDefinitions
|> List.map (fun x -> x.VariableName)
|> Set.ofList
|> Seq.map _.VariableName
|> Set.ofSeq
def.SelectionSet
|> ValidationResult.collect (checkVariablesDefinedInSelection fragmentDefinitions varNames path)
| _ -> Success)
Expand All @@ -1338,7 +1339,7 @@ module Ast =
| ObjectValue obj -> go (Map.toList obj |> List.map snd)
| ListValue xs -> go xs
| _ -> false)
go (args |> List.map (fun x -> x.Value))
go (args |> List.map _.Value)

let rec private variableIsUsedInFragmentSpread
(name : string)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ module FileOperation =
Operation.Types.HeroFields.FriendsFields.EdgesFields.NodeFields.Human(name = "Leia Organa", homePlanet = "Alderaan")
Operation.Types.HeroFields.FriendsFields.EdgesFields.NodeFields.Droid(name = "C-3PO", primaryFunction = "Protocol")
Operation.Types.HeroFields.FriendsFields.EdgesFields.NodeFields.Droid(name = "R2-D2", primaryFunction = "Astromech") |]
let friends = result.Data.Value.Hero.Value.Friends.Edges |> Array.map (fun x -> x.Node)
let friends = result.Data.Value.Hero.Value.Friends.Edges |> Array.map _.Node
friends |> equals expectedFriends
result.Data.Value.Hero.Value.HomePlanet |> equals (Some "Tatooine")
let actual = normalize <| sprintf "%A" result.Data
Expand Down
2 changes: 1 addition & 1 deletion tests/FSharp.Data.GraphQL.Tests/DeferredTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ let sub =
{ FieldName = "live"
TypeName = "Data"
Filter = (fun (x : TestSubject) (y : TestSubject) -> x.id = y.id)
Project = (fun x -> x.live) }
Project = _.live }

schemaConfig.LiveFieldSubscriptionProvider.Register sub

Expand Down
Loading