anchor.diff:                  else AstError.AsResult (onError directive, path)
               else Success)
   
  -    let rec private checkDirectivesInSelectionSet (schemaInfo : SchemaInfo) (fragmentDefinitions : FragmentDefinition list) (path : Path) (visitedFragments : string list ref) (selectionSet : Selection list) =
  -        selectionSet
  -        |> collectResults (checkDirectivesInValidLocationOnSelection schemaInfo fragmentDefinitions path visitedFragments)
  -
  -    and private checkDirectivesInFragment (schemaInfo : SchemaInfo)  (fragmentDefinitions : FragmentDefinition list) (path : Path) (visitedFragments : string list ref) (frag : FragmentDefinition) =
  -        let expectedLocation =
  -            match frag.Name with
  -            | Some _ -> DirectiveLocation.FRAGMENT_DEFINITION
  -            | None -> DirectiveLocation.INLINE_FRAGMENT
  +    type private InlineFragmentContext =
  +        { Schema : SchemaInfo
  +          FragmentDefinitions : FragmentDefinition list
  +          Path : Path
  +          Directives : Directive list
  +          SelectionSet : Selection list }
  +
  +    let rec private checkDirectivesInValidLocationOnInlineFragment (ctx : InlineFragmentContext) =
           let directivesValid =
  -            frag.Directives
  -            |> collectResults (validateDirective schemaInfo path expectedLocation (fun d ->
  -                match frag.Name with
  -                | Some fragName -> sprintf "Fragment definition '%s' has a directive '%s', but this directive location is not supported by the schema definition." fragName d.Name
  -                | None -> sprintf "An inline fragment has a directive '%s', but this directive location is not supported by the schema definition." d.Name))
  -        match frag.Name with
  -        | Some fragName when List.contains fragName !visitedFragments -> directivesValid
  -        | _ -> directivesValid @@ checkDirectivesInSelectionSet schemaInfo fragmentDefinitions path visitedFragments frag.SelectionSet
  -
  -    and private checkDirectivesInValidLocationOnSelection (schemaInfo : SchemaInfo) (fragmentDefinitions : FragmentDefinition list) (path : Path) (visitedFragments : string list ref) =
  +            ctx.Directives
  +            |> collectResults (validateDirective ctx.Schema ctx.Path DirectiveLocation.INLINE_FRAGMENT (fun d -> 
  +                sprintf "An inline fragment has a directive '%s', but this directive location is not supported by the schema definition." d.Name))
  +        let directivesValidInSelectionSet =
  +            ctx.SelectionSet
  +            |> collectResults (checkDirectivesInValidLocationOnSelection ctx.Schema ctx.FragmentDefinitions ctx.Path)
  +        directivesValid @@ directivesValidInSelectionSet
  +
  +    and private checkDirectivesInValidLocationOnSelection (schemaInfo : SchemaInfo) (fragmentDefinitions : FragmentDefinition list) (path : Path) =
           function
           | Field field ->
               let path = field.AliasOrName :: path
  
positive.code:                 match operation.Name with
                  | Some operationName -> sprintf "%s operation '%s' has a directive '%s', but this directive location is not supported by the schema definition." (operation.OperationType.ToString()) operationName directiveDef.Name
                  | None -> sprintf "This %s operation has a directive '%s', but this directive location is not supported by the schema definition." (operation.OperationType.ToString()) directiveDef.Name))
          let operationsValid =
              operation.SelectionSet
              |> collectResults (checkDirectivesInValidLocationOnSelection schemaInfo fragmentDefinitions path visitedFragments)
          directivesValid @@ operationsValid
  
      let internal validateDirectivesAreInValidLocations (ctx : ValidationContext) =
          let fragmentDefinitions = ctx.FragmentDefinitions |> List.map (fun x -> x.Definition)
          let visitedFragments = ref []
          ctx.Document.Definitions
          |> collectResults (fun def ->
              let path = def.Name |> Option.toList
              match def with
              | OperationDefinition odef -> checkDirectivesInOperation ctx.Schema fragmentDefinitions path visitedFragments odef
              | FragmentDefinition frag -> checkDirectivesInFragment ctx.Schema fragmentDefinitions path visitedFragments frag)
  
      let rec private getDirectiveNamesInSelection (path : Path) (selection : Selection) : (Path * string list) list =
          match selection with
  
negative.code:                           Path = path
                            SelectionSet = def.SelectionSet }
                      OperationDefinitionInfo { Definition = def
                                                SelectionSet = getSelectionSetInfo [] opCtx }))
          { Definitions = fragmentInfos @ operationInfos
            Schema = schemaInfo
            Document = ast }
  