question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`~all` or `*` should work in `fields` too

See original GitHub issue

Hey there! I was looking at graphql until I found you awesome library, thank you! I don’t have to add another yet API 🗡️

The question is: We have two models with a lot of fields, e.g

class Order:
    field0 = ....
    field1 = ...
    ...
    field35 = ...
   restaurant=Restaurant

class Restaurant:
   field0 = ...
   field1 = ...
   ...
   field60 = ....

And I want to make a request that will get All fields from Order, expand Restaurant, but only field0\field1 How can I achieve it with drf-flex?

I tried to solve it these ways:

  1. GET /orders/?expand=restaurant - but it gives too much fields, I really want to only two from Restaurant because we have about 100 orders in a list and all of them will contain 60 additional fields
  2. GET /orders/?fields=field0,field1,...,field35,restaurant.field0,restaurant.field1&expand=restaurant - In this case I get that I want to, but I have to add all of fields to params, and I really don’t want to do it on the frontend 😃
  3. GET /orders/?expand=restaurant - give me too much fields too

What I really want to can be achieved with GET /orders/?fields=~all,restaurant.field0, restaurant.field2&expand=restaurant

But looks like ~all works only in expand and not on fields, right?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
allburovcommented, May 16, 2022

I finally had a change to update the library in production and test the new feature. It works!

Thank you a lot for supporting such a great project! 😃

1reaction
rsinger86commented, Aug 8, 2021

I see your point here and agree this should should work the way you describe. I think it should go further and allow specifying all fields at nested levels, eg fields=restaurant.*. Hopefully I’ll get to this in the next few weeks. I appreciate the useful suggestion.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Is it better to specialize in one field or to work at ... - Quora
The answer should carry one of my live experience. When I was in my college days and was pursuing my commerce graduation, I...
Read more >
Should You Explore Fields & Career Interests Outside Your ...
It's okay to engage in other fields and interests. You don't need to be tied down to one profession just because you've worked...
Read more >
Embrace Your Paths: Why Having Multiple Jobs is a Good Thing
You Can Go Global​​ If you're interested in working around the world, having a multitude of skills in different fields can not only...
Read more >
Should You Take a Job That's Not in Your Chosen Field?
You enter college, choose a major, and then work in your chosen field when you graduate. But these days it's not so straightforward....
Read more >
Explore These 13 Career Fields | Indeed.com
Knowing the various career fields will help you be able to choose the right job based on your talents, education and interests. In...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found