private void ValidateFragmentSpreadIsPossible( ISyntaxNode node, IDocumentValidatorContext context) { if (context.Types.Count > 1 && context.Types.TryPeek(out IType type) && type.IsComplexType()) { INamedType typeCondition = type.NamedType(); INamedType parentType = context.Types[context.Types.Count - 2].NamedType(); if (!IsCompatibleType(parentType, typeCondition)) { context.Errors.Add( ErrorBuilder.New() .SetMessage( "The parent type does not match the type condition on the fragment.") .AddLocation(node) .SetPath(context.CreateErrorPath()) .SetExtension("typeCondition", typeCondition.Visualize()) .SetFragmentName(node) .SpecifiedBy("sec-Fragment-spread-is-possible") .Build()); } } }
public static IError FragmentOnlyCompositeType( this IDocumentValidatorContext context, ISyntaxNode node, INamedType type) { return(ErrorBuilder.New() .SetMessage(Resources.ErrorHelper_FragmentOnlyCompositeType) .AddLocation(node) .SetPath(context.CreateErrorPath()) .SetExtension("typeCondition", type.Visualize()) .SetFragmentName(node) .SpecifiedBy("sec-Fragments-On-Composite-Types") .Build()); }
public static IError FragmentNotPossible( this IDocumentValidatorContext context, ISyntaxNode node, INamedType typeCondition, INamedType parentType) { return(ErrorBuilder.New() .SetMessage(Resources.ErrorHelper_FragmentNotPossible) .AddLocation(node) .SetPath(context.CreateErrorPath()) .SetExtension("typeCondition", typeCondition.Visualize()) .SetExtension("selectionSetType", parentType.Visualize()) .SetFragmentName(node) .SpecifiedBy("sec-Fragment-spread-is-possible") .Build()); }