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

Prisma client - chaining API after array #3126

Open
divyenduz opened this Issue Sep 18, 2018 · 3 comments

Comments

Projects
None yet
5 participants
@divyenduz
Copy link
Contributor

commented Sep 18, 2018

Is your feature request related to a problem? Please describe.
Prisma client does not emit the chaining API when we run into an array. The reason for that is we can have multiple solutions and we want the community to choose the API.

Describe the solution you'd like
Currently, the client just stops when the chaining API reaches an array.

In the new API, client.users().friends() can return an array of friends or an array of users with friends.

Similarly, client.users().book() can return an array of books or an array of users with book.

We can add to this API in an additive fashion.

Describe alternatives you've considered
Current alternative is to use the direct GraphQL, SQL feature of client.

@kratam

This comment has been minimized.

Copy link

commented Sep 21, 2018

What if we pass an argument which controls which should be the "root" type?
E.g. client.users().book() returns an array of books and client.users().friends({root: true}).book() returns an array of friends with book.

@HyveMynd

This comment has been minimized.

Copy link

commented Sep 26, 2018

Im a fan of the Objection.js style of eager loading. That framework uses a simple relation expression string to describe how to eagerly load relationships and which ones should/should not be loaded.

For example:

// Returns an array of users with the friends (user model) array populated
client.users().eager('friends')

// Returns an array of users with the books array populated 
client.users().eager('books') 

// Each person has the `.books` property populated with Books objects. 
// The `.friends` property contains the User's friends. 
// Each friend also has the `books` and `friends` relations eagerly fetched.
client.users().eager('[books, friends.[books, friends]')

I believe its simple yet powerful enough to easily define very complex relationships with ease.

@stale

This comment has been minimized.

Copy link

commented Jan 9, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 10 days if no further activity occurs. Thank you for your contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.