コード例 #1
0
 private CompilerContext(
     IObjectType type,
     IImmutableStack <IObjectField> path,
     SelectionSetNode selectionSet,
     SelectionVariants selectionVariants,
     bool isInternalSelection,
     IDictionary <ISelectionNode, SelectionIncludeCondition> includeConditionLookup,
     IImmutableList <ISelectionOptimizer> optimizers,
     Stack <CompilerContext> backlog,
     IDictionary <SelectionSetNode, SelectionVariants> selectionVariantsLookup,
     HashSet <(SelectionSetNode, NameString)> processed)
コード例 #2
0
        public Operation(
            string id,
            DocumentNode document,
            OperationDefinitionNode definition,
            ObjectType rootType,
            Dictionary <SelectionSetNode, SelectionVariants> selectionSets)
        {
            Id         = id;
            Document   = document;
            Definition = definition;

            RootType = rootType;
            Type     = definition.Operation;

            if (definition.Name?.Value is { } name)
            {
                Name = name;
            }

            // we ensure that there is at least one selection set to be executed even if
            // all roots were deferred.
            SelectionVariants rootSelectionVariants = selectionSets[definition.SelectionSet];
            ISelectionSet     selectionSet          = rootSelectionVariants.GetSelectionSet(rootType);

            if (selectionSet.Selections.Count == 0 && selectionSet.Fragments.Count > 0)
            {
                var fragments = selectionSet.Fragments.ToList();
                selectionSet = fragments[0].SelectionSet;
                fragments.RemoveAt(0);
                fragments.AddRange(selectionSet.Fragments);
                selectionSet = new SelectionSet(
                    selectionSet.Selections,
                    fragments,
                    selectionSet.IsConditional);
                rootSelectionVariants.ReplaceSelectionSet(rootType, selectionSet);
            }

            RootSelectionVariants = rootSelectionVariants;
            _selectionSets        = selectionSets;
        }
コード例 #3
0
 private CompilerContext(
     Stack <CompilerContext> backlog,
     IObjectType type,
     SelectionSetNode selectionSet,
     SelectionVariants selectionVariants,
     IImmutableList <ISelectionOptimizer> optimizers,
     IDictionary <SelectionSetNode, SelectionVariants> selectionVariantsLookup)
 {
     Type                   = type;
     Path                   = ImmutableStack <IObjectField> .Empty;
     Fields                 = new Dictionary <string, Selection>();
     SelectionSet           = selectionSet;
     SelectionVariants      = selectionVariants;
     IsInternalSelection    = false;
     IncludeConditionLookup =
         new Dictionary <ISelectionNode, SelectionIncludeCondition>();
     Optimizers      = optimizers;
     IsConditional   = false;
     _processed      = new HashSet <(SelectionSetNode, NameString)>();
     _backlog        = backlog;
     _variantsLookup = selectionVariantsLookup;
 }