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

Making OpenStruct as optional break things #579

Closed
kujma10 opened this issue Apr 4, 2024 · 3 comments
Closed

Making OpenStruct as optional break things #579

kujma10 opened this issue Apr 4, 2024 · 3 comments

Comments

@kujma10
Copy link

kujma10 commented Apr 4, 2024

Hello,

we have been using graphql gem in our project (quite an old version - 1.11.10). New version of Json (2.7.2) (updated automatically by range ~->) caused namespace conflicts with graphql gem resulting an error uninitialized constant GraphQL::Compatibility::ExecutionSpecification::SpecificationSchema::OpenStruct on this line. As a temporary fix we had to lock the version back to 2.7.1.
The breaking change: #565

As a long term fix we will be looking to update graphql but posting it here in case this update causes issues for others too. Also, maybe worth to look into that change from "Json" perspective too.

Thanks

@ebendev
Copy link

ebendev commented Apr 4, 2024

We had the same issue and what it amounts to is that code in our project was making use of OpenStruct from Ruby without explicitly doing any require 'ostruct'. It's actually the change in #577 that revealed this flaw, as that's what causes JSON::GenericObject to not be loaded when the json gem is required/loaded, which means the require 'ostruct' line in lib/json/generic_object.rb (which is still there, btw) is not executed until that file is explicitly loaded.

Anyone seeing this after upgrading to json 2.7.2 merely needs to add require 'ostruct' in their project wherever they are using OpenStruct.

@hsbt
Copy link
Member

hsbt commented Apr 5, 2024

Thanks for your report.

Unfortunately, It's not json issue. Every gem should require dependent libraries themselves.

Anyone seeing this after upgrading to json 2.7.2 merely needs to add require 'ostruct' in their project wherever they are using OpenStruct.

Correct. I'm not sure what usage that in your application. You can simply fix this to add require "ostruct" in your config/application.rb if you use Rails.

@hsbt hsbt closed this as not planned Won't fix, can't repro, duplicate, stale Apr 5, 2024
@kujma10
Copy link
Author

kujma10 commented Apr 5, 2024

Thanks @ebendev and @hsbt. The issue got resolved by adding require "ostruct". Ideally it should be graphql gem requiring that (most likely it does in newer versions) but definetely this is better workaround for us than locking down the json gem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants