Skip to content

Support for embedded struct type in resolver #331

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

Closed
gxb5443 opened this issue May 15, 2019 · 3 comments · Fixed by #338
Closed

Support for embedded struct type in resolver #331

gxb5443 opened this issue May 15, 2019 · 3 comments · Fixed by #338

Comments

@gxb5443
Copy link

gxb5443 commented May 15, 2019

I would like my resolver to expand on an existing struct type, like from another package, when using UseFieldResolvers. To do that, I compose the objects by embedded the base struct inside the resolver struct. However, this doesn't compile because it looks like graphql-go only traverses the first level of fields to find the one that satisfies the schema. This would be helpful so I don't have to implement tedious resolver methods for every field.

package resolvers

import "github.com/gxb5443/project1/users"

type AdminResolver struct {
  users.Admin
}
@jseibert
Copy link

Strongly agreed. This would allow composing GraphQL types from DB types while keeping them separate, without requiring tons of boilerplate.

@eloyekunle
Copy link
Contributor

In progress: #338

@dnutels
Copy link

dnutels commented Jul 3, 2019

This is a fairly crucial topic. Ambiguity should be resolved in the same manner all other issues with schema -> type are resolved, by panicing on mismatch, just like a missing resolver does.

Separating the types, which should really be auto-generated and external to the client code, from the resolvers is an extremely valuable thing.

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

Successfully merging a pull request may close this issue.

4 participants