Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion: new "API" to createLoader #277

Open
noghartt opened this issue Dec 17, 2021 · 3 comments
Open

Suggestion: new "API" to createLoader #277

noghartt opened this issue Dec 17, 2021 · 3 comments

Comments

@noghartt
Copy link
Contributor

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 },
});
@Tsugami
Copy link

Tsugami commented Dec 17, 2021

I like this.

@daniloab
Copy link

feel free to do a poc and send a pr, but this will be a bigger breaking change

@noghartt
Copy link
Contributor Author

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.

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants