Esempio n. 1
0
        public Mutation(UploadRepository uploads)
        {
            Field <FileGraphType>(
                "singleUpload",
                arguments: new QueryArguments(
                    new QueryArgument <UploadGraphType> {
                Name = "file"
            }),
                resolve: context =>
            {
                var file = context.GetArgument <IFormFile>("file");
                return(uploads.Save(file));
            });

            Field <ListGraphType <FileGraphType> >(
                "multipleUpload",
                arguments: new QueryArguments(
                    new QueryArgument <ListGraphType <UploadGraphType> > {
                Name = "files"
            }),
                resolve: context =>
            {
                var files = context.GetArgument <IEnumerable <IFormFile> >("files");
                return(Task.WhenAll(files.Select(file => uploads.Save(file))));
            });
        }
Esempio n. 2
0
 public Query(UploadRepository uploads)
 {
     Field <ListGraphType <FileGraphType> >("uploads", resolve: ctx => uploads.Files);
 }