public void ApplyTo(ISchema schema)
        {
            schema.AllTypes.Apply(item =>
            {
                var complex = item as IComplexGraphType;
                complex?.Fields.Apply(field =>
                {
                    var resolver = new MiddlewareResolver(field.Resolver);

                    FieldMiddlewareDelegate app = context => resolver.Resolve(context);
                    app = Build(app);

                    field.Resolver = new FuncFieldResolver <object>(context =>
                    {
                        try
                        {
                            var result = app.Invoke(context);
                            result.ConfigureAwait(false);
                            return(result.Result);
                        }
                        catch (AggregateException ex)
                        {
                            throw new Exception(ex.InnerException.Message, ex.InnerException);
                        }
                    });
                });
            });
        }
예제 #2
0
        public void ApplyTo(ISchema schema)
        {
            foreach (var complex in schema.AllTypes.OfType <IComplexGraphType>())
            {
                foreach (var field in complex.Fields)
                {
                    var resolver = new MiddlewareResolver(field.Resolver);

                    FieldMiddlewareDelegate app = Build(resolver.Resolve);

                    field.Resolver = new FuncFieldResolver <object>(app.Invoke);
                }
            }
        }
예제 #3
0
        public void ApplyTo(ISchema schema)
        {
            schema.AllTypes.Apply(item =>
            {
                var complex = item as IComplexGraphType;
                complex?.Fields.Apply(field =>
                {
                    var resolver = new MiddlewareResolver(field.Resolver);

                    FieldMiddlewareDelegate app = Build(resolver.Resolve);

                    field.Resolver = new FuncFieldResolver <object>(app.Invoke);
                });
            });
        }
예제 #4
0
        public void ApplyTo(ISchema schema)
        {
            // allocation free optimization if no middlewares are defined
            if (!Empty)
            {
                foreach (var complex in schema.AllTypes.OfType <IComplexGraphType>())
                {
                    foreach (var field in complex.Fields)
                    {
                        var resolver = new MiddlewareResolver(field.Resolver);

                        var fieldMiddlewareDelegate = Build(resolver.Resolve, schema);

                        field.Resolver = new FuncFieldResolver <object>(fieldMiddlewareDelegate.Invoke);
                    }
                }
            }
        }