private void ResolveFragmentSpread( ObjectType type, FragmentSpreadNode fragmentSpread, Action <QueryError> reportError, Dictionary <string, FieldSelection> fields) { Fragment fragment = _fragments.GetFragment( fragmentSpread.Name.Value); if (fragment != null && DoesTypeApply(fragment.TypeCondition, type)) { CollectFields(type, fragment.SelectionSet, reportError, fields); } }
private void ResolveFragmentSpread( ObjectType type, FragmentSpreadNode fragmentSpread, Path path, FieldVisibility fieldVisibility, IDictionary <string, FieldInfo> fields) { Fragment fragment = _fragments.GetFragment( fragmentSpread.Name.Value); if (fragment != null && DoesTypeApply(fragment.TypeCondition, type)) { CollectFields( type, fragment.SelectionSet, path, fieldVisibility, fields); } }
private void ResolveFields( ObjectType type, ISelectionNode selection, Action <QueryError> reportError, Dictionary <string, FieldSelection> fields) { if (selection is FieldNode fs) { string fieldName = fs.Name.Value; if (fieldName.StartsWith("__")) { ResolveIntrospectionField(type, fs, reportError, fields); } else if (type.Fields.TryGetValue(fieldName, out Field field)) { string name = fs.Alias == null ? fs.Name.Value : fs.Alias.Value; fields[name] = new FieldSelection(fs, field, name); } else { reportError(new FieldError( "Could not resolve the specified field.", fs)); } } else if (selection is FragmentSpreadNode fragmentSpread) { Fragment fragment = _fragments.GetFragments(fragmentSpread.Name.Value) .FirstOrDefault(t => DoesFragmentTypeApply(type, t.TypeCondition)); if (fragment != null) { CollectFields(type, fragment.SelectionSet, reportError, fields); } } else if (selection is InlineFragmentNode inlineFragment) { Fragment fragment = _fragments.GetFragment(inlineFragment); if (DoesFragmentTypeApply(type, fragment.TypeCondition)) { CollectFields(type, fragment.SelectionSet, reportError, fields); } } }