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

question about implementing dynamic data sources #211

Closed
sijad opened this issue May 14, 2020 · 3 comments
Closed

question about implementing dynamic data sources #211

sijad opened this issue May 14, 2020 · 3 comments

Comments

@sijad
Copy link

sijad commented May 14, 2020

I'm trying to create dynamic data source to be able define resolvers similar to samsarahq/thunder:

type Friend struct {
  FirstName string
  LastName string
}

func (f *Friend) FullName() string {
  return fmt.Sprintf("%s %s", f.FirstName, f.LastName)
}

I need to pass parent value (f *Friend) to its resolvers, but I'm not sure how this can be implemented using TypeFieldConfiguration and datasources.

I really appreciate any hints or examples.

@jensneuse
Copy link
Member

@sijad
Copy link
Author

sijad commented May 14, 2020

thanks,

Update: yes that was useful, thanks again

I'm looking for a way to pass an struct instance (e.g. f *Friend) to datasource resolver (e.g. func (f *Friend) FullName() string) or func FullName(f *Friend) string))
resolver should be able to access to the object instance somehow, one way might be to recreate TypeFieldConfiguration with each request and pass the instance via config, I'm note sure how efficient that'd be though or is there a better way?

@jensneuse
Copy link
Member

Please reopen or create an issue if you have any further questions.

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

2 participants