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

entgql: support SkipMutationCreateInput (and update) on entity #598

Merged
merged 1 commit into from
Jul 24, 2024

Conversation

freb
Copy link
Contributor

@freb freb commented Jul 23, 2024

Before this change, when SkipMutationCreateInput was annotated on an entity, the CreateXxxInput was omitted from the gql_mutation_input.go generated types, but still included in the ent.graphql generated schema. The same was true for SkipMutationUpdateInput.

To work around this, you could use entgql.Mutations to select only the ones you want generated. But, according to the annotation comments, using SkipMutationCreateInput in this way should be supported.

For example, this works as expected:

func (File) Annotations() []schema.Annotation {
	return []schema.Annotation{
		entgql.Mutations(entgql.MutationUpdate()),
	}
}

While this does not (it still generates CreateFileInput in ent.graphql):

func (File) Annotations() []schema.Annotation {
	return []schema.Annotation{
		entgql.Mutations(),
		entgql.Skip(entgql.SkipMutationCreateInput),
	}
}

This change adds the proper checks to buildMutationInputs to omit the specified mutation inputs from the GraphQL schema.

There are no entities in the example code using a skip annotation at the entity level.

Before this change, when SkipMutationCreateInput was annotated on an
entity, the CreateXxxInput was omitted from the gql_mutation_input.go
generated types, but still included in the ent.graphql generated schema.
The same was true for SkipMutationUpdateInput.

To work around this, you could use entgql.Mutations to select only the
ones you want generated. But, according to the annotation comments,
using SkipMutationCreateInput in this way should be supported.

This change adds the proper checks to buildMutationInputs to omit the
specified mutation inputs from the GraphQL schema.
@a8m a8m requested review from a8m and giautm July 24, 2024 04:19
@a8m
Copy link
Member

a8m commented Jul 24, 2024

Thanks for the contribution, @freb.

This is a breaking change, but @giautm and I will discuss if this can be added with version update.

@giautm
Copy link
Collaborator

giautm commented Jul 24, 2024

Thank you for your contribution

@giautm giautm merged commit 7fc697f into ent:master Jul 24, 2024
4 checks passed
@a8m
Copy link
Member

a8m commented Jul 24, 2024

Thanks for the contribution, @freb.

This is a breaking change, but @giautm and I will discuss if this can be added with version update.

Too fast @giautm. I will bump a version

github-merge-queue bot referenced this pull request in infratographer/x Aug 8, 2024
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [entgo.io/contrib](https://togithub.com/ent/contrib) | `v0.4.5` ->
`v0.6.0` |
[![age](https://developer.mend.io/api/mc/badges/age/go/entgo.io%2fcontrib/v0.6.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/go/entgo.io%2fcontrib/v0.6.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/go/entgo.io%2fcontrib/v0.4.5/v0.6.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/go/entgo.io%2fcontrib/v0.4.5/v0.6.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>ent/contrib (entgo.io/contrib)</summary>

### [`v0.6.0`](https://togithub.com/ent/contrib/releases/tag/v0.6.0)

[Compare
Source](https://togithub.com/ent/contrib/compare/v0.5.0...v0.6.0)

#### What's Changed

- all: update gqlgen pkg by
[@&#8203;ronenlu](https://togithub.com/ronenlu) in
[/~https://github.com/ent/contrib/pull/583](https://togithub.com/ent/contrib/pull/583)
- entgql/template: improve goimports time by adding missing imports by
[@&#8203;a8m](https://togithub.com/a8m) in
[/~https://github.com/ent/contrib/pull/584](https://togithub.com/ent/contrib/pull/584)
- ci: use node20 actions because node16 actions are deprecated by
[@&#8203;Arthur1](https://togithub.com/Arthur1) in
[/~https://github.com/ent/contrib/pull/588](https://togithub.com/ent/contrib/pull/588)
- all: bump ent and atlas to latest version by
[@&#8203;giautm](https://togithub.com/giautm) in
[/~https://github.com/ent/contrib/pull/596](https://togithub.com/ent/contrib/pull/596)
- entgql: add annotation Deprecated for deprecated field by
[@&#8203;luantranminh](https://togithub.com/luantranminh) in
[/~https://github.com/ent/contrib/pull/595](https://togithub.com/ent/contrib/pull/595)
- entgql: support SkipMutationCreateInput (and update) on entity by
[@&#8203;freb](https://togithub.com/freb) in
[/~https://github.com/ent/contrib/pull/598](https://togithub.com/ent/contrib/pull/598)

#### New Contributors

- [@&#8203;ronenlu](https://togithub.com/ronenlu) made their first
contribution in
[/~https://github.com/ent/contrib/pull/583](https://togithub.com/ent/contrib/pull/583)
- [@&#8203;Arthur1](https://togithub.com/Arthur1) made their first
contribution in
[/~https://github.com/ent/contrib/pull/588](https://togithub.com/ent/contrib/pull/588)
- [@&#8203;luantranminh](https://togithub.com/luantranminh) made their
first contribution in
[/~https://github.com/ent/contrib/pull/595](https://togithub.com/ent/contrib/pull/595)
- [@&#8203;freb](https://togithub.com/freb) made their first
contribution in
[/~https://github.com/ent/contrib/pull/598](https://togithub.com/ent/contrib/pull/598)

**Full Changelog**:
ent/contrib@v0.5.0...v0.6.0

### [`v0.5.0`](https://togithub.com/ent/contrib/compare/v0.4.5...v0.5.0)

[Compare
Source](https://togithub.com/ent/contrib/compare/v0.4.5...v0.5.0)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR was generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View the
[repository job log](https://developer.mend.io/github/infratographer/x).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOC4yMC4xIiwidXBkYXRlZEluVmVyIjoiMzguMjAuMSIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOltdfQ==-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
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