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

Get queried properties in the current request #280

Closed
fuintis opened this issue Oct 26, 2018 · 5 comments
Closed

Get queried properties in the current request #280

fuintis opened this issue Oct 26, 2018 · 5 comments

Comments

@fuintis
Copy link

fuintis commented Oct 26, 2018

Is there a way within resolvers functions to get the properties requested by the client?

This feature sounds very useful to implement a mechanism that allow to fine tuning, say, a DB query with only a required data.

Anyone knows about this?

Many thx in advance.

@pavelnikolov
Copy link
Member

There has been such requests in the past. I'll close this issue as a duplicate of #17
The easiest workaround is to use a dynamic resolver with a Golang chan, which blocks until the field has been provided. It'll only call the fields that have been requested. The downside is that you'll not know the fields in advance.
You can also take a look at the example dataloader that @tonyghita has written.

@lfv89
Copy link

lfv89 commented Jan 21, 2019

Hey @pavelnikolov

Quick question, how could dataloader help in this case?

If my understanding is correct, dataloader helps avoiding n + 1 queries by batching results. Could it really help reducing the amount of fields returned by a query as well? If so, how could we pass to it which fields to return while still using graphql-go?

@pavelnikolov
Copy link
Member

The dataloader doesn't reduce the number of fields being queried AFAIK.

@lfv89
Copy link

lfv89 commented Jan 22, 2019

Thanks @pavelnikolov

If that's the case then, could you be so kind to to elaborate more on what you said before about the workaround using a dynamic resolver? A solution for this problem highly interests us.

@pavelnikolov
Copy link
Member

pavelnikolov commented Jan 22, 2019

I haven't thought about how to get a particular subset of fields from a DB 🤔

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