Пример #1
0
        private void CompleteResolver(
            ITypeInitializationContext context)
        {
            if (Resolver == null)
            {
                Resolver = context.GetResolver(Name);
            }

            Middleware = context.CreateMiddleware(
                _middlewareComponents, Resolver,
                IsIntrospectionField ||
                DeclaringType.IsIntrospectionType());

            if (Resolver == null && Middleware == null)
            {
                if (_executableDirectives.Any())
                {
                    Middleware = ctx => Task.CompletedTask;
                }
                else
                {
                    context.ReportError(new SchemaError(
                                            $"The field `{context.Type.Name}.{Name}` " +
                                            "has no resolver.", (INamedType)context.Type));
                }
            }

            _middlewareComponents = null;
        }
Пример #2
0
 private void CompleteResolver(
     ITypeInitializationContext context)
 {
     if (Resolver == null)
     {
         Resolver = context.GetResolver(Name);
         if (Resolver == null &&
             _executableDirectives.All(
                 t => t.Middleware == null))
         {
             context.ReportError(new SchemaError(
                                     $"The field `{context.Type.Name}.{Name}` " +
                                     "has no resolver.", context.Type));
         }
     }
 }
Пример #3
0
        protected override void OnCompleteType(
            ITypeInitializationContext context)
        {
            base.OnCompleteType(context);

            if (Resolver == null)
            {
                Resolver = context.GetResolver(Name);
                if (Resolver == null)
                {
                    context.ReportError(new SchemaError(
                                            $"The field `{context.Type.Name}.{Name}` " +
                                            "has no resolver.", context.Type));
                }
            }
        }
Пример #4
0
        private void CompleteResolver(
            ITypeInitializationContext context)
        {
            if (Resolver == null)
            {
                Resolver = context.GetResolver(Name);
            }

            // TODO : review if that is what we want. Sometimes a middleware can replace a resolver ... but not all middleware components are resolver replacements.
            Resolver = context.CreateFieldMiddleware(
                _middlewareComponents, Resolver);

            // TODO : All executable middlewars should have a middleware so could we rewrite this?
            if (Resolver == null && _executableDirectives.All(
                    t => t.Middleware == null))
            {
                context.ReportError(new SchemaError(
                                        $"The field `{context.Type.Name}.{Name}` " +
                                        "has no resolver.", context.Type));
            }

            _middlewareComponents = null;
        }