Skip to content

GraphQL::Schema::Visibility preload crashes if query type is not set first #5454

@cocoahero

Description

@cocoahero

If the GraphQL::Schema::Visibility plugin is "used" with preload: true prior to configuring the schema's root types, an exception will be raised.

NoMethodError: undefined method 'kind' for nil

gems/graphql-2.5.14/lib/graphql/schema/visibility/profile.rb:177:in 'GraphQL::Schema::Visibility::Profile#field'
gems/graphql-2.5.14/lib/graphql/schema/visibility/profile.rb:332:in 'block in GraphQL::Schema::Visibility::Profile#preload'
gems/graphql-2.5.14/lib/graphql/schema/visibility/profile.rb:328:in 'Array#each'
gems/graphql-2.5.14/lib/graphql/schema/visibility/profile.rb:328:in 'GraphQL::Schema::Visibility::Profile#preload'
gems/graphql-2.5.14/lib/graphql/schema/visibility.rb:99:in 'block in GraphQL::Schema::Visibility#preload'
gems/graphql-2.5.14/lib/graphql/schema/visibility.rb:97:in 'Hash#each'
gems/graphql-2.5.14/lib/graphql/schema/visibility.rb:97:in 'GraphQL::Schema::Visibility#preload'
gems/graphql-2.5.14/lib/graphql/schema/visibility.rb:44:in 'GraphQL::Schema::Visibility#initialize'
gems/graphql-2.5.14/lib/graphql/schema/visibility.rb:20:in 'Class#new'
gems/graphql-2.5.14/lib/graphql/schema/visibility.rb:20:in 'GraphQL::Schema::Visibility.use'
gems/graphql-2.5.14/lib/graphql/schema.rb:322:in 'GraphQL::Schema.use'

This is likely a programmer error, however a sanity check with proper error message might be more helpful. It is not immediately obvious that certain plugins need to be configured in a certain order.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions