示例#1
0
    protected override ISyntaxVisitorAction Enter(
        InlineFragmentNode node,
        IDocumentValidatorContext context)
    {
        if (node.TypeCondition is null)
        {
            return(Continue);
        }

        if (context.Schema.TryGetType(
                node.TypeCondition.Name.Value,
                out INamedOutputType type))
        {
            if (type.IsCompositeType())
            {
                ValidateFragmentSpreadIsPossible(
                    node, context,
                    context.Types.Peek().NamedType(),
                    type);
                context.Types.Push(type);
                return(Continue);
            }

            context.Errors.Add(context.FragmentOnlyCompositeType(node, type.NamedType()));
            return(Skip);
        }

        context.Errors.Add(context.FragmentTypeConditionUnknown(node, node.TypeCondition));
        return(Skip);
    }