public RoutesController(IIOServiceContext context, IHttpContextAccessor httpContextAccessor, IGoogleDriveService googleDriveService, IVtexAPIService vtexAPIService, IDriveImportRepository driveImportRepository) { this._context = context ?? throw new ArgumentNullException(nameof(context)); this._httpContextAccessor = httpContextAccessor ?? throw new ArgumentNullException(nameof(httpContextAccessor)); this._googleDriveService = googleDriveService ?? throw new ArgumentNullException(nameof(googleDriveService)); this._vtexAPIService = vtexAPIService ?? throw new ArgumentNullException(nameof(vtexAPIService)); this._driveImportRepository = driveImportRepository ?? throw new ArgumentNullException(nameof(driveImportRepository)); }
public Mutation(IGoogleDriveService googleDriveService, IDriveImportRepository driveImportRepository, IVtexAPIService vtexAPIService) { Name = "Mutation"; Field <StringGraphType>( "importImages", resolve: context => { return(vtexAPIService.DriveImport()); }); Field <BooleanGraphType>( "revokeToken", arguments: new QueryArguments( new QueryArgument <StringGraphType> { Name = "accountName", Description = "Account Name" } ), resolve: context => { bool revoked = googleDriveService.RevokeGoogleAuthorizationToken().Result; if (revoked) { string accountName = context.GetArgument <string>("accountName"); driveImportRepository.SaveFolderIds(null, accountName); } return(revoked); }); Field <StringGraphType>( "googleAuthorize", resolve: context => { return(googleDriveService.GetGoogleAuthorizationUrl()); }); Field <StringGraphType>( "createSheet", resolve: context => { return(googleDriveService.CreateSheet()); }); Field <StringGraphType>( "processSheet", resolve: context => { return(vtexAPIService.SheetImport()); }); Field <StringGraphType>( "addImages", resolve: context => { return(googleDriveService.ClearAndAddImages()); }); }