github-community-projects / graphql-client

A Ruby library for declaring, composing and executing GraphQL queries
MIT License
42 stars 218 forks source link

Breaks due to changes in graphql 2.3.5 #27

Closed eizengan closed 4 months ago

eizengan commented 4 months ago

After updating dependencies in a project using this gem we have begun to see failures during query parsing:

Caused by NoMethodError: undefined method 'map' for nil from...gems/graphql-client-0.22.0/lib/graphql/client/schema/interface_type.rb:24:in `define_class'

At a(n uninformed) glance, this appears to be somehow related to graphql 2.3.5 switching from string-based to class-based keys here:

Using graphql 2.3.4

[3] pry(#<Module:0x00000001363208c0>::Actor)> definition.client.possible_types
=> {"__Schema"=>[#<Class:0x000000012ff71680>],
   "__Type"=>[#<Class:0x000000012ff71360>],
   "__Field"=>[#<Class:0x000000012ff71040>],
   "__Directive"=>[#<Class:0x000000012ff70d20>],
   ...

Using graphql 2.3.5:

[2] pry(#<Module:0x00000001363208c0>::Actor)> definition.client.possible_types
=> {#<Class:0x0000000136325640>=>[#<Class:0x0000000136325640>],
 #<Class:0x0000000136325280>=>[#<Class:0x0000000136325280>],
 #<Class:0x0000000136324f60>=>[#<Class:0x0000000136324f60>],
 #<Class:0x0000000136324c40>=>[#<Class:0x0000000136324c40>],
 #<Class:0x0000000136324920>=>[#<Class:0x0000000136324920>],
rmosolgo commented 4 months ago

Hey, thanks for reporting this! Yes, I bet you're right about the cause. I forgot about the possibility of outside callers of this method 😖

I worked up a patch in #28 and I'm going to update the GraphQL-Ruby changelog to mention this as a breaking change.

eizengan commented 4 months ago

Cool - we'll pin the dependency in our gemfile until that fix releases. Didn't expect a super-fast turnaround, but I'm certainly grateful for it!

rmosolgo commented 4 months ago

v0.23.0 is on Rubygems with this fix -- please let me know if you have any more trouble with it!

eizengan commented 4 months ago

@rmosolgo - fix is worky in our app. Thanks again! 🙇‍♂️