コード例 #1
0
        private SelectionSetNode Visit(ISelectionVariants selectionVariants)
        {
            var fragments = new List <InlineFragmentNode>();

            foreach (IObjectType objectType in selectionVariants.GetPossibleTypes())
            {
                var typeContext = (ObjectType)objectType;
                var selections  = new List <ISelectionNode>();

                foreach (Selection selection in selectionVariants.GetSelectionSet(typeContext)
                         .Selections.OfType <Selection>())
                {
                    SelectionSetNode?selectionSetNode =
                        selection.SelectionSet is not null
                            ? Visit(_selectionSets[selection.SelectionSet])
                            : null;

                    selections.Add(CreateSelection(selection, selectionSetNode));
                }

                fragments.Add(new InlineFragmentNode(
                                  null,
                                  new NamedTypeNode(typeContext.Name),
                                  Array.Empty <DirectiveNode>(),
                                  new SelectionSetNode(selections)));
            }

            return(new SelectionSetNode(fragments));
        }
コード例 #2
0
        private SelectionSetNode Visit(ISelectionVariants selectionVariants)
        {
            var fragments = new List <InlineFragmentNode>();

            foreach (IObjectType objectType in selectionVariants.GetPossibleTypes())
            {
                var typeContext = (ObjectType)objectType;
                var selections  = new List <ISelectionNode>();

                foreach (Selection selection in selectionVariants.GetSelectionSet(typeContext)
                         .Selections.OfType <Selection>())
                {
                    var directives = new List <DirectiveNode>();

                    if (selection.IncludeConditions is { })