public void Add(IResolverMap resolvers, ISubscriberMap?subscribers) { foreach (var(typeName, fields) in resolvers.GetTypes()) { foreach (var field in fields) { var resolver = resolvers?.GetResolver(typeName, field); var subscriber = subscribers?.GetSubscriber(typeName, field); if (resolver is not null) { Add(typeName, field, resolver, subscriber); } } } if (subscribers is not null) { foreach (var(typeName, fields) in subscribers.GetTypes()) { foreach (var field in fields) { var resolver = resolvers?.GetResolver(typeName, field); var subscriber = subscribers?.GetSubscriber(typeName, field); if (subscriber is not null) { Add(typeName, field, subscriber); } } } } }
public static SchemaBuilder UseResolversAndSubscribers( this SchemaBuilder builder, IResolverMap resolvers, ISubscriberMap subscribers = null) { foreach (var type in builder.GetTypes <ObjectType>()) { builder.Connections(connections => { foreach (var field in connections.GetFields(type)) { var resolver = resolvers.GetResolver(type.Name, field.Key); if (resolver != null) { connections.GetOrAddResolver(type, field.Key) .Run(resolver); } var subscriber = subscribers?.GetSubscriber(type.Name, field.Key); if (subscriber != null) { connections.GetOrAddSubscriber(type, field.Key) .Run(subscriber); } } }); } return(builder); }
public Resolver? GetResolver(string type, string fieldName) { return _resolvers.GetResolver(type, fieldName); }
public static Resolver GetResolver(this IResolverMap map, ComplexType type, KeyValuePair <string, IField> field) { return(map.GetResolver(type.Name, field.Key)); }
public static Resolver?GetResolver(this IResolverMap map, ObjectDefinition type, FieldDefinition field) { return(map.GetResolver(type.Name, field.Name)); }