private void ResolveFragmentSpread( CompilerContext context, FragmentSpreadNode fragmentSpread, SelectionIncludeCondition?includeCondition) { if (_fragments.GetFragment(fragmentSpread.Name.Value) is { } fragmentInfo&& DoesTypeApply(fragmentInfo.TypeCondition, context.Type)) { FragmentDefinitionNode fragmentDefinition = fragmentInfo.FragmentDefinition !; if (fragmentSpread.IsDeferrable() && AllowFragmentDeferral(context, fragmentSpread, fragmentDefinition)) { CompilerContext deferContext = context.Branch(fragmentInfo); CompileSelectionSet(deferContext); context.RegisterFragment(new Fragment( context.Type, fragmentSpread, fragmentDefinition, deferContext.GetSelectionSet(), context.IsInternalSelection, includeCondition)); } else { CollectFields( context, fragmentInfo.SelectionSet, includeCondition); } } }
private void ResolveFragmentSpread( CompilerContext context, FragmentSpreadNode fragmentSpread, SelectionIncludeCondition?includeCondition) { if (_fragments.GetFragment(fragmentSpread.Name.Value) is { } fragmentInfo&& DoesTypeApply(fragmentInfo.TypeCondition, context.Type)) { FragmentDefinitionNode fragmentDefinition = fragmentInfo.FragmentDefinition !; if (fragmentDefinition.SelectionSet.Selections.Count == 0) { throw OperationCompiler_FragmentNoSelections(fragmentDefinition); } var reference = new SpreadReference(context.SelectionPath, fragmentSpread); if (!context.Spreads.TryGetValue(reference, out var selectionSet)) { selectionSet = fragmentDefinition.SelectionSet.WithSelections( fragmentDefinition.SelectionSet.Selections); context.Spreads.Add(reference, selectionSet); } if (fragmentSpread.IsDeferrable() && AllowFragmentDeferral(context, fragmentSpread, fragmentDefinition)) { CompilerContext deferContext = context.Branch(selectionSet); CompileSelectionSet(deferContext); context.RegisterFragment(new Fragment( _nextFragmentId++, context.Type, fragmentSpread, fragmentDefinition, deferContext.GetSelectionSet(), context.IsInternalSelection, includeCondition)); } else { CollectFields(context, selectionSet, includeCondition); } } }