public Task <object> Execute(IResolutionContext resolutionContext, Func <IResolutionContext, object> executor)
        {
            var fieldInfo = resolutionContext.FieldInfo;

            foreach (var argument in fieldInfo.Arguments)
            {
                ResolveArgument(argument, resolutionContext);
            }
            var start = (FieldResolutionDelegate)(async ctx =>
            {
                var result = executor(ctx);
                if (result is Task)
                {
                    result = await result.GetTaskResult().ConfigureAwait(false);
                }
                return(Unwrapper.Unwrap(result));
            });
            var resolver = start;

            foreach (var executionFilter in fieldInfo.ExecutionFilters.AsEnumerable().Reverse())
            {
                var previousResolver = resolver;
                resolver = ctx => executionFilter.Execute(ctx, previousResolver);
            }
            return(resolver(resolutionContext));
        }
Esempio n. 2
0
 private object GetSource(GraphFieldInfo fieldInfo, IResolutionContext context)
 {
     var source = context.Source;
     if (source == null ||
         source.GetType() == typeof(ImplementViewerAttribute.QueryViewer) ||
         source.GetType() == typeof(ImplementViewerAttribute.MutationViewer) ||
         source.GetType() == typeof(ImplementViewerAttribute.SubscriptionViewer))
     {
         var declaringType = fieldInfo.DeclaringType.TypeRepresentation.AsType();
         source = context.DependencyInjector?.Resolve(declaringType.GetTypeInfo()) ?? fieldInfo.SchemaInfo.TypeResolutionDelegate(declaringType);
     }
     source = Unwrapper.Unwrap(source);
     return source;
 }
Esempio n. 3
0
 private object Unwrap(object value) => _unwrapper?.Unwrap(value) ?? value;
 protected object Unwrap(object value) =>
 _unwrapper.Unwrap(value);