YouTag icon indicating copy to clipboard operation
YouTag copied to clipboard

Library backup

Open youstanzr opened this issue 4 years ago • 1 comments

The library can be backed up by a simple json that contains all songs' id and other string information (no thumbnail image) or some special string representation of the library. This string can be saved or shared with others. To restore library, you would paste this string into the app and it would automatically go through each song, download it using the id then modify its details to match the backup string.

youstanzr avatar Apr 28 '20 01:04 youstanzr

Issue #37 has a good discussion about SwiftNIO and some links to forks with most of the work done. @jseibert had most of it working IIRC.

paulofaria avatar May 28 '18 12:05 paulofaria

Thanks @paulofaria for the quick answer ! I have been looking into #37 and also compared a lot to the GraphQL-js.

The problem is that a futures result is a future. And I think if I can get that resolved, somehow all the tests passes.

Maybe @jseibert can help me out so we can finish it?

kimdv avatar May 28 '18 12:05 kimdv

@kimdv can you give more details as to what problem you're facing? Generally, yes, you want the result to be a future, so I'm confused.

If you're willing to take a vapor/core dependency, https://github.com/digits-labs/graphiti https://github.com/digits-labs/graphql are now rock-solid for me. (Ignore the readme's, I haven't updated them)

You need to route the futures all the way through, i.e. graphql(...) returns an EventLoopFuture<Map>

In Graphiti, the schema-builders support both future fields, and normal fields:

try builder.field(name: "organization", futureType: Organization.self) { (selfInstance, _: NoArguments, req: Request, _) in
    // Returns an EventLoopFuture<Organization>
    return try selfInstance.organization.get(on: req)
}

try builder.field(name: "name", type: String.self) { (selfInstance, _: NoArguments, req: Request, _) in
    // Returns a String directly, no future needed. 
    return selfInstance.name
}

In Vapor, the Request object is an EventLoopGroup, which I have forcibly routed through as the Context param.

jseibert avatar May 28 '18 15:05 jseibert

Maybe I'm misunderstanding something.

I try to update the tests, and the test crashes: As you can see on the attached screenshot, the value for __schema is a <EventLoopFuture<Any?>

Either I need to update the test or I'm doing something wong.. :)

screen shot 2018-05-28 at 19 41 38

kimdv avatar May 28 '18 17:05 kimdv

Looks like your implementation isn't entirely correct. Data should be a Future<[String: Any]>, not a [String: Future<Any>]. You need to flatten the dictionary futures.

jseibert avatar May 29 '18 01:05 jseibert

@jseibert I found a solution. Using Vapors/Core flatMap solved all my problems

kimdv avatar May 29 '18 07:05 kimdv

@paulofaria I also have Graphiti ready and updated to use Future

kimdv avatar May 30 '18 08:05 kimdv

This is great! I'm a bit off the grid now so I can't properly review everything. I'll review everything by sunday though. Thanks a lot!

paulofaria avatar May 30 '18 10:05 paulofaria