private void CompleteResolver( ICompletionContext context, ObjectFieldDefinition definition) { bool isIntrospectionField = IsIntrospectionField || DeclaringType.IsIntrospectionType(); Resolver = definition.Resolver; if (!isIntrospectionField || Resolver == null) { // gets resolvers that were provided via type extensions, // explicit resolver results or are provided through the // resolver compiler. FieldResolver resolver = context.GetResolver(definition.Name); Resolver = GetMostSpecificResolver( context.Type.Name, Resolver, resolver); } IReadOnlySchemaOptions options = context.DescriptorContext.Options; bool skipMiddleware = options.FieldMiddleware == FieldMiddlewareApplication.AllFields ? false : isIntrospectionField; Middleware = FieldMiddlewareCompiler.Compile( context.GlobalComponents, definition.MiddlewareComponents.ToArray(), Resolver, skipMiddleware); if (Resolver == null && Middleware == null) { if (_executableDirectives.Any()) { Middleware = ctx => Task.CompletedTask; } else { context.ReportError(SchemaErrorBuilder.New() .SetMessage( $"The field `{context.Type.Name}.{Name}` " + "has no resolver.") .SetCode(ErrorCodes.Schema.NoResolver) .SetTypeSystemObject(context.Type) .AddSyntaxNode(definition.SyntaxNode) .Build()); } } }
private void CompleteResolver( ICompletionContext context, ObjectFieldDefinition definition) { bool isIntrospectionField = IsIntrospectionField || DeclaringType.IsIntrospectionType(); Resolver = definition.Resolver; if (Resolver == null || !isIntrospectionField) { var fieldReference = new FieldReference( context.Type.Name, definition.Name); FieldResolver resolver = context.GetResolver(fieldReference); if (resolver != null) { Resolver = resolver.Resolver; } } Middleware = FieldMiddlewareCompiler.Compile( context.GlobalComponents, definition.MiddlewareComponents.ToArray(), Resolver, isIntrospectionField); if (Resolver == null && Middleware == null) { if (_executableDirectives.Any()) { Middleware = ctx => Task.CompletedTask; } else { context.ReportError(SchemaErrorBuilder.New() .SetMessage( $"The field `{context.Type.Name}.{Name}` " + "has no resolver.") .SetCode(TypeErrorCodes.NoResolver) .SetTypeSystemObject(context.Type) .AddSyntaxNode(definition.SyntaxNode) .Build()); } } }