private static void CompileMiddleware(
            ITypeCompletionContext context,
            ObjectFieldDefinition definition,
            ITypeReference argumentTypeReference,
            FieldMiddleware placeholder,
            string?scope)
        {
            IType resolvedType = context.GetType <IType>(argumentTypeReference);

            if (!(resolvedType.ElementType().NamedType() is ISortInputType type))
            {
                throw Sorting_TypeOfInvalidFormat(resolvedType);
            }

            ISortConvention convention = context.DescriptorContext.GetSortConvention(scope);

            var fieldDescriptor = ObjectFieldDescriptor.From(context.DescriptorContext, definition);

            convention.ConfigureField(fieldDescriptor);

            MethodInfo factory    = _factoryTemplate.MakeGenericMethod(type.EntityType.Source);
            var        middleware = (FieldMiddleware)factory.Invoke(null, new object[] { convention }) !;
            var        index      = definition.MiddlewareComponents.IndexOf(placeholder);

            definition.MiddlewareComponents[index] = middleware;
        }
Exemplo n.º 2
0
        private static void CompileMiddleware(
            ITypeCompletionContext context,
            ObjectFieldDefinition definition,
            ITypeReference argumentTypeReference,
            FieldMiddleware placeholder,
            string?scope)
        {
            IFilterInputType  type       = context.GetType <IFilterInputType>(argumentTypeReference);
            IFilterConvention convention = context.DescriptorContext.GetFilterConvention(scope);

            var fieldDescriptor = ObjectFieldDescriptor.From(context.DescriptorContext, definition);

            convention.ConfigureField(fieldDescriptor);

            MethodInfo factory    = _factoryTemplate.MakeGenericMethod(type.EntityType.Source);
            var        middleware = (FieldMiddleware)factory.Invoke(null, new object[] { convention }) !;
            var        index      = definition.MiddlewareComponents.IndexOf(placeholder);

            definition.MiddlewareComponents[index] = middleware;
        }