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

Fixes #32214 - Register query field with a resolver #8794

Merged
merged 1 commit into from
Oct 20, 2021

Conversation

xprazak2
Copy link
Contributor

@xprazak2 xprazak2 commented Sep 24, 2021

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

@theforeman-bot
Copy link
Member

Issues: #32214

@xprazak2
Copy link
Contributor Author

Continues where #8415 stopped, seems like I cannot reopen when I force-pushed.

@ezr-ondrej
Copy link
Member

Do we have a use-case for it yet? :)

@xprazak2
Copy link
Contributor Author

xprazak2 commented Oct 6, 2021

Yes: theforeman/foreman_openscap#506

Copy link
Member

@ezr-ondrej ezr-ondrej left a comment

Choose a reason for hiding this comment

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

Just one nit, from what I managed to understand

@ezr-ondrej
Copy link
Member

[test katello]

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
@xprazak2
Copy link
Contributor Author

Seems like apply_type method might not be needed as Foreman::Module does the same thing.

Copy link
Member

@ezr-ondrej ezr-ondrej left a comment

Choose a reason for hiding this comment

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

Thanks @xprazak2 ! 👍

@ezr-ondrej ezr-ondrej merged commit ba49a33 into theforeman:develop Oct 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants