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

Allow forcing resolvers on generated types #190

Merged
merged 1 commit into from
Jul 14, 2018

Conversation

vektah
Copy link
Collaborator

@vektah vektah commented Jul 14, 2018

Fixes #189

@vektah vektah merged commit 0780bf2 into master Jul 14, 2018
@vektah vektah deleted the generated-forced-resolvers branch July 14, 2018 02:00
@flicaflow
Copy link

@vektah thank you for doing this.
I'm just trying out the new feature. I noticed the the auto generated model still has the fields defined despite having a field resolver defined. Wouldn't it be more natural to have this field omitted?

@vektah
Copy link
Collaborator Author

vektah commented Jul 16, 2018

Yeah perhaps, there are a lot of use cases for this stuff though, it might be worth a separate issue to deal with them.

some examples:

  • functions in front of a primitive type eg starwars
  • 1:1 / M:1 mappings where you want the id added to the model
  • 1:M / M:M mappings where you probably dont want anything

@Ehekatl
Copy link

Ehekatl commented Jul 19, 2018

@vektah I found that force resolver doesn't work when fields have already defined in model, it that intend behavior?

e.g.

this won't work

type Host struct {
  id string
  status string
}

type Host implements Node {
  id: ID!
  status: String
}

models:
  Host:
    model: xxx/models.Host
    fields:
      status:
        resolver: true

this works

type Host struct {
  id string
}

type Host implements Node {
  id: ID!
  status: String
}

models:
  Host:
    model: xxx/models.Host
    fields:
      status:
        resolver: true

cgxxv pushed a commit to cgxxv/gqlgen that referenced this pull request Mar 25, 2022
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 this pull request may close these issues.

3 participants