vapor / fluent-kit

Swift ORM (queries, models, and relations) for NoSQL and SQL databases
MIT License
218 stars 116 forks source link

Separate Field property wrappers into separate package #597

Closed lmcd closed 8 months ago

lmcd commented 8 months ago

I have a model In my project that is simply serialised and sent to a Swift server to process. My client-side build needs a whole bunch of nio dependancies simply to accommodate some properties decorated with a @Field annotation.

Is it possible to separate this so I can use @Field, @ID etc without needing swift-nio?

0xTim commented 8 months ago

@lmcd No I don't think it is. The property wrappers require the enclosing type to be a Model to make all the syntactic sugar work and there's not really a way around that.

For sharing models across server and clients, we strongly recommend sharing only DTOs which doesn't have this issue

lmcd commented 8 months ago

There's no way to solve this with protocols? Seems a bit over the top that just defining a model needs to import a massive event loop library and all of its dependancies, and there's no possible way to disentangle the two.

0xTim commented 8 months ago

You can't require property wrappers on properties in a protocol so there's no way for us to achieve this unfortunately

0xTim commented 8 months ago

Will close this out, feel free to reopen if you have any other suggestions