Skip to content

Conversation

@gmcgibbon
Copy link
Contributor

Followup to #5178

Types reference schema, which reference types, so we need to take the part of schema that reference types, and autoload it.

Currently, if you reference GraphQL::Types::String, you'll get:

graphql-ruby/lib/graphql/schema/built_in_types.rb:6:in `<class:Schema>': unin
itialized constant GraphQL::Types::String (NameError)

      "String" => GraphQL::Types::String,
                                ^^^^^^^^
Did you mean?  StringIO
               STDIN
        from graphql-ruby/lib/graphql/schema/built_in_types.rb:3:in `<module:
GraphQL>'
        from graphql-ruby/lib/graphql/schema/built_in_types.rb:2:in `<top (required)>'
        from /opt/rubies/3.3.6/lib/ruby/3.3.0/bundled_gems.rb:69:in `require'
        from /opt/rubies/3.3.6/lib/ruby/3.3.0/bundled_gems.rb:69:in `block (2 levels) in replace_require'
        from graphql-ruby/lib/graphql/schema.rb:1813:in `<top (required)>'
        from /opt/rubies/3.3.6/lib/ruby/3.3.0/bundled_gems.rb:69:in `require'
        from /opt/rubies/3.3.6/lib/ruby/3.3.0/bundled_gems.rb:69:in `block (2 levels) in replace_require'
        from graphql-ruby/lib/graphql/types/string.rb:5:in `<module:Types>'
        from graphql-ruby/lib/graphql/types/string.rb:4:in `<module:GraphQL>'
        from graphql-ruby/lib/graphql/types/string.rb:3:in `<top (required)>'
        from /opt/rubies/3.3.6/lib/ruby/3.3.0/bundled_gems.rb:69:in `require'
        from /opt/rubies/3.3.6/lib/ruby/3.3.0/bundled_gems.rb:69:in `block (2 levels) in replace_require'
        from (irb):1:in `<main>'
        from <internal:kernel>:187:in `loop'
        from bin/console:8:in `<main>'

This fixes the problem. Sorry for not catching this earlier!

Types reference schema, which reference types, so we need to take the
part of schema that reference types, and autoload it.
@rmosolgo
Copy link
Owner

rmosolgo commented Dec 5, 2024

Thanks for the fix! I'll release this very soon... I want to work up a fix for #5178 (comment) too.

@rmosolgo rmosolgo merged commit 72222dd into rmosolgo:master Dec 5, 2024
13 of 15 checks passed
@rmosolgo rmosolgo added this to the 2.4.6 milestone Dec 5, 2024
@gmcgibbon gmcgibbon deleted the fix_type_loading branch December 10, 2024 18:38
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

Successfully merging this pull request may close these issues.

2 participants