You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First off, great job. I struggled in my own code traversing the ast_node to determine the include/preload models to use in the resultant query. What you've done has made my life much easier.
I ran into an issue when using a UnionType to express a polymorphic association and then attempting to traverse the ast_node to build the references. The issue is that the UnionType is expressing a polymorphic association. The polymorphic association does not have a direct class reference. So in the following line an empty result is returned and the code errs on the next line.
I don't think there is a way to 'fix' this since the only way that I know of to determine the models that a polymorphic association references is to do a table scan. I am simply punting at this point by checking if !selection_name.nil? and hitting next if it is. Maybe you can solve this in another way. It's not a high priority for me at this point since we only use polymorphic associations in two cases in our app.
selection_name = class_name.reflections.with_indifferent_access[selection.name].options[:class_name]
begin
current_class_name = selection_name.singularize.classify.constantize
dependencies[selection.name.to_sym] = get_implied_includes(current_class_name, selection)
rescue
Rails.logger "polymorphic associations do not have a resolvable class_name"
end
The text was updated successfully, but these errors were encountered:
First off, great job. I struggled in my own code traversing the ast_node to determine the include/preload models to use in the resultant query. What you've done has made my life much easier.
I ran into an issue when using a UnionType to express a polymorphic association and then attempting to traverse the ast_node to build the references. The issue is that the UnionType is expressing a polymorphic association. The polymorphic association does not have a direct class reference. So in the following line an empty result is returned and the code errs on the next line.
https://github.com/nettofarah/graphql-query-resolver/blob/master/lib/graphql/query_resolver.rb#L66
I don't think there is a way to 'fix' this since the only way that I know of to determine the models that a polymorphic association references is to do a table scan. I am simply punting at this point by checking if !selection_name.nil? and hitting next if it is. Maybe you can solve this in another way. It's not a high priority for me at this point since we only use polymorphic associations in two cases in our app.
The text was updated successfully, but these errors were encountered: