コード例 #1
0
ファイル: ResolversMap.cs プロジェクト: pekkah/tanka-graphql
    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);
                    }
                }
            }
        }
    }
コード例 #2
0
        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);
        }
コード例 #3
0
 public Resolver? GetResolver(string type, string fieldName)
 {
     return _resolvers.GetResolver(type, fieldName);
 }
コード例 #4
0
ファイル: IResolverMap.cs プロジェクト: digvand/tanka-graphql
 public static Resolver GetResolver(this IResolverMap map, ComplexType type, KeyValuePair <string, IField> field)
 {
     return(map.GetResolver(type.Name, field.Key));
 }
コード例 #5
0
 public static Resolver?GetResolver(this IResolverMap map, ObjectDefinition type, FieldDefinition field)
 {
     return(map.GetResolver(type.Name, field.Name));
 }