Exemplo n.º 1
0
        public override object VisitFragmentDefinition(GraphQLParser.FragmentDefinitionContext context)
        {
            var name = context.fragmentName().GetText();
            var type = Visit(context.typeCondition().typeName()) as NamedType;

            var fragmentDefinition = new FragmentDefinition();

            NewNode(fragmentDefinition, context);

            fragmentDefinition.Name = name;
            fragmentDefinition.Type = type;

            var directiveContext = context.directives();

            if (directiveContext != null)
            {
                var directives = Visit(directiveContext) as Directives;
                fragmentDefinition.Directives = directives;
            }

            var selectionContext = context.selectionSet();

            if (selectionContext != null)
            {
                var selections = Visit(selectionContext) as SelectionSet;
                fragmentDefinition.SelectionSet = selections;
            }

            return(fragmentDefinition);
        }