graphql-mongo-helpers
graphql-mongo-helpers copied to clipboard
Suggestion: new "API" to `createLoader`
Suggestion
Instead of using just only one argument as an object with named properties, could be interesting to turn it in more arguments with something like: createLoader(model, loaderName, options)
.
IMO, with it, can be separated the concern by domains, the required args: model
and loaderName
, and the options
as an optional argument with default values.
Code Example
// Maybe in `loaderName` could be transform User to `UserLoader` under the hood
createLoader(UserModel, 'User', {
viewerCanSee = defaultViewerCanSee,
filterMapping = {},
isAggregate = false,
shouldValidateContextUser = false,
defaultFilters = {},
defaultConditions = {},
defaultSort = { createdAt: -1 },
});
I like this.
feel free to do a poc and send a pr, but this will be a bigger breaking change
IMO, with it, can be separated the concern by domains, the required args:
model
andloaderName
, and theoptions
as an optional argument with default values.
Yes! It would be a bigger breaking change (probably some major update). I'll try to do POC to implement this (and some other things).