graphql-ruby icon indicating copy to clipboard operation
graphql-ruby copied to clipboard

Union resolve_type doesn't handle string class names

Open fameoflight opened this issue 2 years ago • 1 comments

Describe the bug

At most places in Graphql Schema you can define string as Graphql Type and it's lazily constantized, but not in union resolve_type. Just for sake of consistency Union resolve_type should handle string class names

fameoflight avatar Jul 07 '22 17:07 fameoflight

I'm open to this improvement, but I don't plan to work on it myself. In the meantime, you could work around this by adding a Schema.get_type(type_name) call to your resolve_type method, to turn the name into a type definition. For example:

def self.resolve_type(obj, ctx)
  type_name = # somehow get the typename for obj 
  ctx.schema.get_type(type_name)
end 

Let me know if you have any trouble with that approach!

rmosolgo avatar Jul 14 '22 13:07 rmosolgo

I'm open to supporting this if someone wants to add it, but I don't plan to work on it myself, so I'm closing this issue.

rmosolgo avatar Sep 01 '22 12:09 rmosolgo