Exemplo n.º 1
0
        protected SortVisitorContext(
            ISortInputType initialType)
        {
            if (initialType is null)
            {
                throw new ArgumentNullException(nameof(initialType));
            }

            Types.Push(initialType);
        }
Exemplo n.º 2
0
 public QueryableSortContext(
     ISortInputType initialType,
     bool inMemory)
     : base(initialType)
 {
     InMemory     = inMemory;
     RuntimeTypes = new Stack <IExtendedType>();
     RuntimeTypes.Push(initialType.EntityType);
     Instance.Push(QueryableFieldSelector.New(initialType.EntityType.Source));
 }
        protected ISchema CreateSchemaWith(ISortInputType type, SortConvention convention)
        {
            ISchemaBuilder builder = SchemaBuilder.New()
                                     .AddConvention <ISortConvention>(convention)
                                     .AddSorting()
                                     .AddQueryType(
                c =>
                c.Name("Query")
                .Field("foo")
                .Type <StringType>()
                .Resolver("bar"))
                                     .AddType(type);

            return(builder.Create());
        }
Exemplo n.º 4
0
        private static void CompileMiddleware(
            ICompletionContext context,
            ObjectFieldDefinition definition,
            ITypeReference argumentTypeReference,
            FieldMiddleware placeholder)
        {
            ISortInputType type =
                context.GetType <ISortInputType>(argumentTypeReference);
            Type middlewareType = _middlewareDefinition
                                  .MakeGenericType(type.EntityType);
            FieldMiddleware middleware =
                FieldClassMiddlewareFactory.Create(middlewareType);
            int index = definition.MiddlewareComponents.IndexOf(placeholder);

            definition.MiddlewareComponents[index] = middleware;
        }
        private static void CompileMiddleware(
            ITypeCompletionContext context,
            ObjectFieldDefinition definition,
            ITypeReference argumentTypeReference,
            FieldMiddleware placeholder,
            string?scope)
        {
            ISortInputType  type       = context.GetType <ISortInputType>(argumentTypeReference);
            ISortConvention convention = context.DescriptorContext.GetSortConvention(scope);

            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.º 6
0
        public static IError CreateNonNullError <T>(
            ISortField field,
            IValueNode value,
            ISortVisitorContext <T> context)
        {
            ISortInputType sortType = context.Types.OfType <ISortInputType>().First();

            return(ErrorBuilder.New()
                   .SetMessage(
                       DataResources.ErrorHelper_CreateNonNullError,
                       context.Fields.Peek().Name,
                       sortType.Visualize())
                   .AddLocation(value)
                   .SetExtension("expectedType", new NonNullType(field.Type).Visualize())
                   .SetExtension("sortType", sortType.Visualize())
                   .Build());
        }
Exemplo n.º 7
0
        protected ISchema CreateSchemaWith(
            ISortInputType type,
            SortConvention convention,
            params SortConventionExtension[] extensions)
        {
            ISchemaBuilder builder = SchemaBuilder.New()
                                     .AddConvention <ISortConvention>(convention)
                                     .AddSorting()
                                     .AddQueryType(
                c =>
                c.Name("Query")
                .Field("foo")
                .Type <StringType>()
                .Resolve("bar"))
                                     .AddType(type);

            foreach (var extension in extensions)
            {
                builder.AddConvention <ISortConvention>(extension);
            }

            return(builder.Create());
        }
        private static void CompileMiddleware(
            ITypeCompletionContext context,
            ObjectFieldDefinition definition,
            ITypeReference argumentTypeReference,
            FieldMiddleware placeholder)
        {
            ISortingNamingConvention convention =
                context.DescriptorContext.GetSortingNamingConvention();

            ISortInputType type           = context.GetType <ISortInputType>(argumentTypeReference);
            Type           middlewareType = _middlewareDefinition.MakeGenericType(type.EntityType);

            FieldMiddleware middleware =
                FieldClassMiddlewareFactory.Create(
                    middlewareType,
                    (
                        typeof(SortMiddlewareContext),
                        SortMiddlewareContext.Create(convention.ArgumentName
                                                     )));

            int index = definition.MiddlewareComponents.IndexOf(placeholder);

            definition.MiddlewareComponents[index] = middleware;
        }
Exemplo n.º 9
0
 public ExecutorBuilder(ISortInputType inputType)
 {
     _inputType = inputType;
 }
 public MongoDbSortVisitorContext(ISortInputType initialType)
     : base(initialType)
 {
 }
Exemplo n.º 11
0
 public Neo4JSortVisitorContext(ISortInputType initialType)
     : base(initialType)
 {
 }