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

added directives to create and update mutations #469

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

lucvankessel
Copy link

This is the fix for this issue i created a few days ago.
Right now however it will add it to the type, create and update mutation.
And i would like to have the option in the future to skip a directive on a type or mutation (create/update) is that something you also agree with adding?

@lucvankessel
Copy link
Author

Hey @a8m,
Do you have additional questions about this mr? Or are there tests that need to be written still? would love to know if there is anything i can do to help get this merged.

@giautm
Copy link
Collaborator

giautm commented Apr 6, 2023

Hello @lucvankessel, thank you for your contribution and patience here.

I and Ariel already have a discussion about this PR. We think we need some changes to this PR before accepting this. The Directives annotation should work on scoped objects (Object Type or Object Input). So it avoids breaking change with current users.

Bellow is my suggestion API.

entgql.Directives(entgql.Deprecated("Use `description` instead.")).
  OnTypes("Todo"). // Default
  OnInputs("CreateTodoInput", "CreateTodoUpdate")

cc @a8m

@lucvankessel
Copy link
Author

lucvankessel commented Apr 6, 2023

@giautm thanks for the response.
Is there a reason why all the directives have the same inputs and types instead of deciding that on a per directive basis?
And why not use the skip mode(or a similar thing) for this? Seeing as that will negate (i think) mistakes in typing the types and inputs.
I see why it needs to be done a different way/needs to be made sure it behaves like it does right now without the directives. Maybe it could use a default value and/or a check on a potential OnInput field or SkipMode field on the Directives type. that way it also stays close to the object it relates to.

Thanks in advance for your reply. Will look into the suggested implementation in the mean time,
cc @a8m

@lucvankessel
Copy link
Author

Hey @giautm and @a8m,
Sorry for the bump again.
After looking into it for a bit i woud like your feedback on the following API example

entgql.Directives(entgql.Deprecated("User `description` instead.")).OnCreateInput().OnUpdateInput().SkipType()

This (i think) will do the same thing you suggested but without the typed types and inputs.
It also makes sure it is backwards compatible and still enable the directives on the inputs i want.
It is still not the most perfect solution (my preference still goes out to using the existing skip mode type and making a skipDirectives field for it in the annotation, or even better having it on the directive itself so some directives can be on the update, some on the create and some on the type. for these skip fields a default value would be set to make sure it behaves like it does now)

@process0
Copy link

process0 commented May 3, 2023

entgql.Directives(entgql.Deprecated("User `description` instead.")).OnCreateInput().OnUpdateInput().SkipType()

IMO, this API is more readable than the one proposed by @giautm . This is a useful feature, whats needed to get this moving?

@lucvankessel
Copy link
Author

Could i get a reply from one of the devs on my comments? @giautm @a8m

@syssam
Copy link

syssam commented Jul 29, 2023

@lucvankessel, @giautm how about ent/ent#3588

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.

4 participants