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

How to skip gqlgen to generate resolver for specific field #2948

Open
fekuna opened this issue Feb 28, 2024 · 0 comments
Open

How to skip gqlgen to generate resolver for specific field #2948

fekuna opened this issue Feb 28, 2024 · 0 comments

Comments

@fekuna
Copy link

fekuna commented Feb 28, 2024

What happened?

I wanted gqlgen to skip creating a resolver for a specific field, in this case, to skip creating a resolver for the "permissions" field. Can gqlgen accomplish this?

type Role {
  id: UUID!
  name: String!
  displayName: String!
  description: String
  permissions: [RolePermissions]
  createdAt: Time!
  updatedAt: Time!
}

type RolePermissions {
  id: UUID!
  parentId: UUID
  name: String!
  displayName: String!
  children: [RolePermissions]!
  createdAt: Time!
  updatedAt: Time!
}

I added "resolver: false" to the gqlgen.yml configuration file, but it didn't work as expected. This feature seems to only force gqlgen to generate a resolver, not skip it.

Role:
    model: models.Role
    fields:
      permissions:
        resolver: false

What did you expect?

When I ran the generate command, I expected gqlgen to skip creating the following resolver:

// Permissions is the resolver for the permissions field.
func (r *roleResolver) Permissions(ctx context.Context, obj *models.Role) ([]*graphqlModels.RolePermissions, error) {
	panic(fmt.Errorf("not implemented: Permissions - permissions"))
}

versions

  • go run github.com/99designs/gqlgen version? v0.17.40
  • go version? 1.21.6
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

1 participant