예제 #1
0
        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());
                }
            }
        }
예제 #2
0
 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());
 }
예제 #3
0
 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());
 }