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: create plugin for gqlgen [Stage1] #241

Merged
merged 23 commits into from
Mar 5, 2022
Merged

Conversation

giautm
Copy link
Collaborator

@giautm giautm commented Mar 1, 2022

Related: ent/ent#2351

@giautm giautm force-pushed the gqlgen-relay-plugin branch 3 times, most recently from da4957b to a772776 Compare March 1, 2022 22:00
@giautm giautm force-pushed the gqlgen-relay-plugin branch from 0948072 to add22b7 Compare March 1, 2022 22:28
@giautm giautm force-pushed the gqlgen-relay-plugin branch from 2ef09aa to 3b980d2 Compare March 2, 2022 11:13
@giautm giautm force-pushed the gqlgen-relay-plugin branch from 3b980d2 to ce3256a Compare March 2, 2022 12:21
@giautm giautm force-pushed the gqlgen-relay-plugin branch from f73d0e9 to 28e280b Compare March 2, 2022 18:56
entgql/annotation.go Outdated Show resolved Hide resolved
entgql/internal/todoplugin/ent/entc.go Outdated Show resolved Hide resolved
entgql/internal/todoplugin/ent/role/role.go Outdated Show resolved Hide resolved
entgql/internal/todoplugin/ent/schema/todo.go Show resolved Hide resolved
entgql/plugin/plugin.go Outdated Show resolved Hide resolved
entgql/plugin/plugin.go Outdated Show resolved Hide resolved
entgql/plugin/plugin_config.go Outdated Show resolved Hide resolved
entgql/plugin/plugin.go Outdated Show resolved Hide resolved
@giautm giautm marked this pull request as ready for review March 3, 2022 08:20
@giautm giautm requested a review from a8m March 3, 2022 08:20
@giautm giautm changed the title feat: create the entgql plugin for Stage 1 entgql: create plugin for gqlgen [Stage1] Mar 3, 2022
entgql/annotation.go Show resolved Hide resolved
)
if err != nil {
fmt.Fprintln(os.Stderr, err.Error())
os.Exit(3)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why exit code 3?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure, it's come from the original PR. I can fix it by update to Fatal().

entgql/internal/todoplugin/todo.graphql Outdated Show resolved Hide resolved
entgql/plugin/plugin.go Outdated Show resolved Hide resolved
entgql/plugin/plugin.go Outdated Show resolved Hide resolved
entgql/plugin/plugin.go Outdated Show resolved Hide resolved
entgql/plugin/plugin.go Outdated Show resolved Hide resolved
entgql/plugin/plugin_config.go Outdated Show resolved Hide resolved
entgql/plugin/plugin_config.go Outdated Show resolved Hide resolved
Copy link
Member

@a8m a8m left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great progress! I'm going to merge this, even though it's not finished, but I can help with that.

@@ -188,6 +193,14 @@ func WithWhereFilters(b bool) ExtensionOption {
}
}

// WithSchemaGenerator add a hook for generate GQL schema
func WithSchemaGenerator() ExtensionOption {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

That means users can use it even if they don't use gqlgen.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but it require some refactor for WhereInput feature to working as the same way

}
}

type gqlgenPlugin struct {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, but it's actually more complex than setting autobind or the @goModel directive in the generated schema.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

autobind didnt work in all cases. So, the user still need to manual config mapping. Then, we have to read config.yaml to recogine them.

If we can detect and mapping it correctly, we not need to read config.yaml anymore and not must to depends on gqlgen.

@a8m a8m merged commit 1705e21 into ent:master Mar 5, 2022
@a8m
Copy link
Member

a8m commented Mar 5, 2022

@cliedeman, I added you as a co-author of this PR. Thank you both for your contribution ❤️ 🙏

image

@giautm giautm deleted the gqlgen-relay-plugin branch March 5, 2022 16:09
@cliedeman
Copy link
Collaborator

🎉
Thanks @a8m glad to see this go in and I appreciate the attribution
@giautm thanks for taking it over the line

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