-
Notifications
You must be signed in to change notification settings - Fork 992
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
Fixes #32214 - Register query field with a resolver #8415
Conversation
xprazak2
commented
Mar 26, 2021
•
edited
Loading
edited
Issues: #32214 |
Foreman::Plugin.register :foreman_plugin do register_graphql_query_field :foo, '::Types::Foo', :field, { :resolver => ::Resolvers::Foos::Foo } # register with lambda instead of a string if type does not resolve to a contant register_graphql_query_field :bars, -> () { [::Types::Bar] }, :field, { :resolver => ::Resolvers::Bars } end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine with this, it make sense I just do not see use-case, so I'm reluctant to merge as we don't have the need for it now.
Could we at least document this in developers docs? Are there even docs for defining plugin GraphQL fields from plugin?
@@ -6,7 +6,11 @@ module GraphqlPluginFields | |||
module ClassMethods | |||
def realize_plugin_query_extensions(source = Foreman::Plugin.graphql_types_registry.plugin_query_fields) | |||
source.map do |plugin_type| | |||
send plugin_type[:field_type], plugin_type[:field_name], Foreman::Module.resolve(plugin_type[:type]) | |||
if plugin_type[:options].empty? | |||
send plugin_type[:field_type], plugin_type[:field_name], Foreman::Module.resolve(plugin_type[:type]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we not allowing lambda types without options?
And why do we even have case for options, can't we just send the empty options and handle them on receiver end?
You are right, this is not needed anywhere just yet. I'll close for now and reopen when it is really needed. Thanks! |