in src/Epam.GraphQL/Savers/DbContextSaver.cs [197:233]
public static IEnumerable<string> GetFieldsForReload<TExecutionContext>(ISaveResult<TExecutionContext> result, IResolveFieldContext context)
{
var initialDictionary = context.SubFields?.ToDictionary(kv => kv.Key, kv => kv.Value.Field);
Guards.AssertIfNull(initialDictionary);
if ((context.FieldDefinition.ResolvedType?.GetType().IsGenericType ?? false) && (context.FieldDefinition.ResolvedType?.GetType().GetGenericTypeDefinition() == typeof(MutationResultGraphType<,>)))
{
if (!initialDictionary.ContainsKey("payload"))
{
return Enumerable.Empty<string>();
}
initialDictionary = initialDictionary["payload"].SelectionSet?.Selections
.Cast<GraphQLField>()
.ToDictionary(f => f.Name.StringValue)
?? new Dictionary<string, GraphQLField>();
}
if (!initialDictionary.ContainsKey(result.FieldName))
{
return Enumerable.Empty<string>();
}
initialDictionary = initialDictionary[result.FieldName].SelectionSet?.Selections.Cast<GraphQLField>()
.ToDictionary(f => f.Name.StringValue)
?? new Dictionary<string, GraphQLField>();
if (!initialDictionary.ContainsKey("payload"))
{
return Enumerable.Empty<string>();
}
var fields = initialDictionary["payload"].GetSubFieldsNames(context.Document.Definitions.OfType<GraphQLFragmentDefinition>(), _ => true);
return fields;
}