示例#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;
        }