Graphql-ruby: 1.9.13 -> 1.9.14 update breaks something

Created on 17 Oct 2019  路  12Comments  路  Source: rmosolgo/graphql-ruby

Hello,

We use this gem in several applications.
The update went ok for most applications but 2 applications yield to this when starting rails server:

/Users/someuser/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/graphql-1.9.14/lib/graphql/schema/traversal.rb:223:in 'validate_type': Mutation is invalid: Mutation must define at least 1 field. 0 defined. (GraphQL::Schema::InvalidTypeError)

Same in development, test and production environments.

We do NOT use Mutation's at all in any of the applications.

I think these PRs have something to do with it
https://github.com/rmosolgo/graphql-ruby/pull/2462/files
https://github.com/rmosolgo/graphql-ruby/pull/2539/files

Most helpful comment

Same issue here.
Solved commenting out mutation Types::MutationType in schema.rb as suggested by @michal-samluk .

Mauro

All 12 comments

Do you have a line mutation Types::MutationType in your schema.rb or similar? Does it work when you remove it?

No, not using mutations or mutation types anywhere in any of our apps.

Hi @lizdeika not sure if it will be needed for debugging, but it will be great if you can share your Ruby and Rails version.

If you can share your GraphQL schema.rb's code too, that might be useful too.

share your GraphQL schema.rb's code

ditto, that would be really helpful, also the full backtrace of the error.

I have a similar problem but for queries. I even added a field for my otherwise empty query to see if that would help, but it does not.

99: from /Users/stevenscott/.gem/ruby/2.5.3/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `require'
     98: from /Users/stevenscott/.gem/ruby/2.5.3/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:257:in `load_dependency'
     97: from /Users/stevenscott/.gem/ruby/2.5.3/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `block in require'
     96: from /Users/stevenscott/.gem/ruby/2.5.3/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
     95: from /Users/stevenscott/.gem/ruby/2.5.3/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require_with_bootsnap_lfi'
     94: from /Users/stevenscott/.gem/ruby/2.5.3/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
     93: from /Users/stevenscott/.gem/ruby/2.5.3/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `block in require_with_bootsnap_lfi'
     92: from /Users/stevenscott/.gem/ruby/2.5.3/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require'
     91: from /Users/stevenscott/.gem/ruby/2.5.3/gems/railties-5.2.3/lib/rails/commands.rb:18:in `<top (required)>'
     90: from /Users/stevenscott/.gem/ruby/2.5.3/gems/railties-5.2.3/lib/rails/command.rb:46:in `invoke'
     89: from /Users/stevenscott/.gem/ruby/2.5.3/gems/railties-5.2.3/lib/rails/command/base.rb:65:in `perform'
     88: from /Users/stevenscott/.gem/ruby/2.5.3/gems/thor-0.20.3/lib/thor.rb:387:in `dispatch'
     87: from /Users/stevenscott/.gem/ruby/2.5.3/gems/thor-0.20.3/lib/thor/invocation.rb:126:in `invoke_command'
     86: from /Users/stevenscott/.gem/ruby/2.5.3/gems/thor-0.20.3/lib/thor/command.rb:27:in `run'
     85: from /Users/stevenscott/.gem/ruby/2.5.3/gems/railties-5.2.3/lib/rails/commands/test/test_command.rb:33:in `perform'
     84: from /Users/stevenscott/.gem/ruby/2.5.3/gems/railties-5.2.3/lib/rails/test_unit/runner.rb:39:in `run'
     83: from /Users/stevenscott/.gem/ruby/2.5.3/gems/railties-5.2.3/lib/rails/test_unit/runner.rb:50:in `load_tests'
     82: from /Users/stevenscott/.gem/ruby/2.5.3/gems/railties-5.2.3/lib/rails/test_unit/runner.rb:50:in `each'
     81: from /Users/stevenscott/.gem/ruby/2.5.3/gems/railties-5.2.3/lib/rails/test_unit/runner.rb:50:in `block in load_tests'
     80: from /Users/stevenscott/.gem/ruby/2.5.3/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `require'
     79: from /Users/stevenscott/.gem/ruby/2.5.3/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:257:in `load_dependency'
     78: from /Users/stevenscott/.gem/ruby/2.5.3/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `block in require'
     77: from /Users/stevenscott/.gem/ruby/2.5.3/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
     76: from /Users/stevenscott/.gem/ruby/2.5.3/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require_with_bootsnap_lfi'
     75: from /Users/stevenscott/.gem/ruby/2.5.3/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
     74: from /Users/stevenscott/.gem/ruby/2.5.3/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `block in require_with_bootsnap_lfi'
     73: from /Users/stevenscott/.gem/ruby/2.5.3/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require'
     72: from /Users/stevenscott/src/github.com/Shopify/accio-client/test/graphql/mutations/register_request_test.rb:1:in `<top (required)>'
     71: from /Users/stevenscott/.gem/ruby/2.5.3/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `require'
     70: from /Users/stevenscott/.gem/ruby/2.5.3/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:257:in `load_dependency'
     69: from /Users/stevenscott/.gem/ruby/2.5.3/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `block in require'
     68: from /Users/stevenscott/.gem/ruby/2.5.3/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
     67: from /Users/stevenscott/.gem/ruby/2.5.3/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require_with_bootsnap_lfi'
     66: from /Users/stevenscott/.gem/ruby/2.5.3/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
     65: from /Users/stevenscott/.gem/ruby/2.5.3/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `block in require_with_bootsnap_lfi'
     64: from /Users/stevenscott/.gem/ruby/2.5.3/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require'
     63: from /Users/stevenscott/src/github.com/Shopify/accio-client/test/test_helper.rb:2:in `<top (required)>'
     62: from /Users/stevenscott/.gem/ruby/2.5.3/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:48:in `require_relative'
     61: from /Users/stevenscott/.gem/ruby/2.5.3/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `require'
     60: from /Users/stevenscott/.gem/ruby/2.5.3/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:257:in `load_dependency'
     59: from /Users/stevenscott/.gem/ruby/2.5.3/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `block in require'
     58: from /Users/stevenscott/.gem/ruby/2.5.3/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
     57: from /Users/stevenscott/.gem/ruby/2.5.3/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require_with_bootsnap_lfi'
     56: from /Users/stevenscott/.gem/ruby/2.5.3/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
     55: from /Users/stevenscott/.gem/ruby/2.5.3/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `block in require_with_bootsnap_lfi'
     54: from /Users/stevenscott/.gem/ruby/2.5.3/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require'
     53: from /Users/stevenscott/src/github.com/Shopify/accio-client/config/environment.rb:2:in `<top (required)>'
     52: from /Users/stevenscott/.gem/ruby/2.5.3/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:48:in `require_relative'
     51: from /Users/stevenscott/.gem/ruby/2.5.3/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `require'
     50: from /Users/stevenscott/.gem/ruby/2.5.3/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:257:in `load_dependency'
     49: from /Users/stevenscott/.gem/ruby/2.5.3/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `block in require'
     48: from /Users/stevenscott/.gem/ruby/2.5.3/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
     47: from /Users/stevenscott/.gem/ruby/2.5.3/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require_with_bootsnap_lfi'
     46: from /Users/stevenscott/.gem/ruby/2.5.3/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
     45: from /Users/stevenscott/.gem/ruby/2.5.3/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `block in require_with_bootsnap_lfi'
     44: from /Users/stevenscott/.gem/ruby/2.5.3/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require'
     43: from /Users/stevenscott/src/github.com/Shopify/accio-client/config/application.rb:7:in `<top (required)>'
     42: from /opt/rubies/2.5.3/lib/ruby/site_ruby/2.5.0/bundler.rb:114:in `require'
     41: from /opt/rubies/2.5.3/lib/ruby/site_ruby/2.5.0/bundler/runtime.rb:65:in `require'
     40: from /opt/rubies/2.5.3/lib/ruby/site_ruby/2.5.0/bundler/runtime.rb:65:in `each'
     39: from /opt/rubies/2.5.3/lib/ruby/site_ruby/2.5.0/bundler/runtime.rb:76:in `block in require'
     38: from /opt/rubies/2.5.3/lib/ruby/site_ruby/2.5.0/bundler/runtime.rb:76:in `each'
     37: from /opt/rubies/2.5.3/lib/ruby/site_ruby/2.5.0/bundler/runtime.rb:81:in `block (2 levels) in require'
     36: from /Users/stevenscott/.gem/ruby/2.5.3/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
     35: from /Users/stevenscott/.gem/ruby/2.5.3/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require_with_bootsnap_lfi'
     34: from /Users/stevenscott/.gem/ruby/2.5.3/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
     33: from /Users/stevenscott/.gem/ruby/2.5.3/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `block in require_with_bootsnap_lfi'
     32: from /Users/stevenscott/.gem/ruby/2.5.3/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require'
     31: from /Users/stevenscott/.gem/ruby/2.5.3/gems/cusco-0.7.0/lib/cusco.rb:8:in `<top (required)>'
     30: from /Users/stevenscott/.gem/ruby/2.5.3/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `require'
     29: from /Users/stevenscott/.gem/ruby/2.5.3/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:257:in `load_dependency'
     28: from /Users/stevenscott/.gem/ruby/2.5.3/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `block in require'
     27: from /Users/stevenscott/.gem/ruby/2.5.3/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
     26: from /Users/stevenscott/.gem/ruby/2.5.3/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require_with_bootsnap_lfi'
     25: from /Users/stevenscott/.gem/ruby/2.5.3/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
     24: from /Users/stevenscott/.gem/ruby/2.5.3/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `block in require_with_bootsnap_lfi'
     23: from /Users/stevenscott/.gem/ruby/2.5.3/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require'
     22: from /Users/stevenscott/.gem/ruby/2.5.3/gems/cusco-0.7.0/lib/cusco/config.rb:3:in `<top (required)>'
     21: from /Users/stevenscott/.gem/ruby/2.5.3/gems/cusco-0.7.0/lib/cusco/config.rb:4:in `<module:Cusco>'
     20: from /Users/stevenscott/.gem/ruby/2.5.3/gems/cusco-0.7.0/lib/cusco/config.rb:5:in `<module:Config>'
     19: from /Users/stevenscott/.gem/ruby/2.5.3/gems/graphql-1.9.14/lib/graphql/schema.rb:653:in `from_definition'
     18: from /Users/stevenscott/.gem/ruby/2.5.3/gems/graphql-1.9.14/lib/graphql/schema/build_from_definition.rb:10:in `from_definition'
     17: from /Users/stevenscott/.gem/ruby/2.5.3/gems/graphql-1.9.14/lib/graphql/schema/build_from_definition.rb:92:in `build'
     16: from /Users/stevenscott/.gem/ruby/2.5.3/gems/graphql-1.9.14/lib/graphql/define/instance_definable.rb:228:in `define'
     15: from /Users/stevenscott/.gem/ruby/2.5.3/gems/graphql-1.9.14/lib/graphql/schema.rb:283:in `define'
     14: from /Users/stevenscott/.gem/ruby/2.5.3/gems/graphql-1.9.14/lib/graphql/schema/validation.rb:15:in `validate'
     13: from /Users/stevenscott/.gem/ruby/2.5.3/gems/graphql-1.9.14/lib/graphql/schema/validation.rb:15:in `each'
     12: from /Users/stevenscott/.gem/ruby/2.5.3/gems/graphql-1.9.14/lib/graphql/schema/validation.rb:17:in `block in validate'
     11: from /Users/stevenscott/.gem/ruby/2.5.3/gems/graphql-1.9.14/lib/graphql/schema/validation.rb:17:in `each'
     10: from /Users/stevenscott/.gem/ruby/2.5.3/gems/graphql-1.9.14/lib/graphql/schema/validation.rb:18:in `block (2 levels) in validate'
      9: from /Users/stevenscott/.gem/ruby/2.5.3/gems/graphql-1.9.14/lib/graphql/schema/validation.rb:149:in `block in <module:Rules>'
      8: from /Users/stevenscott/.gem/ruby/2.5.3/gems/graphql-1.9.14/lib/graphql/schema.rb:322:in `types'
      7: from /Users/stevenscott/.gem/ruby/2.5.3/gems/graphql-1.9.14/lib/graphql/schema.rb:1259:in `rebuild_artifacts'
      6: from /Users/stevenscott/.gem/ruby/2.5.3/gems/graphql-1.9.14/lib/graphql/schema.rb:1259:in `new'
      5: from /Users/stevenscott/.gem/ruby/2.5.3/gems/graphql-1.9.14/lib/graphql/schema/traversal.rb:47:in `initialize'
      4: from /Users/stevenscott/.gem/ruby/2.5.3/gems/graphql-1.9.14/lib/graphql/schema/traversal.rb:128:in `visit'
      3: from /Users/stevenscott/.gem/ruby/2.5.3/gems/graphql-1.9.14/lib/graphql/schema/traversal.rb:128:in `each'
      2: from /Users/stevenscott/.gem/ruby/2.5.3/gems/graphql-1.9.14/lib/graphql/schema/traversal.rb:128:in `block in visit'
      1: from /Users/stevenscott/.gem/ruby/2.5.3/gems/graphql-1.9.14/lib/graphql/schema/traversal.rb:142:in `visit'
/Users/stevenscott/.gem/ruby/2.5.3/gems/graphql-1.9.14/lib/graphql/schema/traversal.rb:223:in `validate_type': Query is invalid: Query must define at least 1 field. 0 defined. (GraphQL::Schema::InvalidTypeError)

Same issue here.
Solved commenting out mutation Types::MutationType in schema.rb as suggested by @michal-samluk .

Mauro

@tostart-pickagreatname , it looks like you're parsing a GraphQL schema definition file, right? Could you share two items from that file:

  • the schema { ... } definition
  • the type Query { ... } definition, if there is one

?

type Query {
}

Where should I see schema { ... } ? the graphql dump does not produce one.

Regarding schema { ... }, there might not be one. Thanks for sharing that.

So, the error message you posted above was:

Query must define at least 1 field. 0 defined. (GraphQL::Schema::InvalidTypeError)

And the file you're parsing contains an empty Query type. How about either:

  • removing the Query type; OR
  • adding a field the the Query type

?

Getting the same error here @rmosolgo. Adding a field does fix the problem. Removing the query type does not. When I remove query from the schema I get this

RuntimeError - Unexpected parent_type: :
  graphql (1.9.15) lib/graphql/schema.rb:423:in `block in get_field'
  graphql (1.9.15) lib/graphql/schema.rb:1279:in `with_definition_error_check'
  graphql (1.9.15) lib/graphql/schema.rb:416:in `get_field'
  graphql (1.9.15) lib/graphql/static_validation/base_visitor.rb:97:in `on_field'
  graphql (1.9.15) lib/graphql/language/visitor.rb:79:in `visit_node'
  graphql (1.9.15) lib/graphql/language/visitor.rb:174:in `on_node_with_modifications'
  graphql (1.9.15) lib/graphql/language/visitor.rb:102:in `block in on_abstract_node'
  graphql (1.9.15) lib/graphql/language/visitor.rb:101:in `on_abstract_node'
  graphql (1.9.15) lib/graphql/language/visitor.rb:123:in `on_operation_definition'
  graphql (1.9.15) lib/graphql/static_validation/definition_dependencies.rb:47:in `on_operation_definition'
  graphql (1.9.15) lib/graphql/static_validation/rules/subscription_root_exists.rb:12:in `on_operation_definition'
  graphql (1.9.15) lib/graphql/static_validation/rules/mutation_root_exists.rb:12:in `on_operation_definition'
  graphql (1.9.15) lib/graphql/static_validation/rules/variable_usages_are_allowed.rb:13:in `on_operation_definition'
  graphql (1.9.15) lib/graphql/static_validation/rules/variables_are_used_and_defined.rb:44:in `on_operation_definition'
  graphql (1.9.15) lib/graphql/static_validation/rules/variable_names_are_unique.rb:20:in `on_operation_definition'
  graphql (1.9.15) lib/graphql/static_validation/rules/fields_have_appropriate_selections.rb:18:in `on_operation_definition'
  graphql (1.9.15) lib/graphql/static_validation/rules/fields_will_merge.rb:24:in `on_operation_definition'
  graphql (1.9.15) lib/graphql/static_validation/rules/operation_names_are_valid.rb:12:in `on_operation_definition'
  graphql (1.9.15) lib/graphql/static_validation/rules/unique_directives_per_location.rb:27:in `block (2 levels) in <module:UniqueDirectivesPerLocation>'
  graphql (1.9.15) lib/graphql/internal_representation/rewrite.rb:68:in `block in on_operation_definition'
  graphql (1.9.15) lib/graphql/internal_representation/rewrite.rb:92:in `push_root_node'
  graphql (1.9.15) lib/graphql/internal_representation/rewrite.rb:68:in `on_operation_definition'
  graphql (1.9.15) lib/graphql/static_validation/base_visitor.rb:76:in `on_operation_definition'
  graphql (1.9.15) lib/graphql/language/visitor.rb:79:in `visit_node'
  graphql (1.9.15) lib/graphql/language/visitor.rb:174:in `on_node_with_modifications'
  graphql (1.9.15) lib/graphql/language/visitor.rb:102:in `block in on_abstract_node'
  graphql (1.9.15) lib/graphql/language/visitor.rb:101:in `on_abstract_node'
  graphql (1.9.15) lib/graphql/language/visitor.rb:123:in `on_document'
  graphql (1.9.15) lib/graphql/static_validation/definition_dependencies.rb:38:in `on_document'
  graphql (1.9.15) lib/graphql/static_validation/rules/variables_are_used_and_defined.rb:79:in `on_document'
  graphql (1.9.15) lib/graphql/static_validation/rules/fragment_spreads_are_possible.rb:26:in `on_document'
  graphql (1.9.15) lib/graphql/static_validation/rules/fragments_are_used.rb:6:in `on_document'
  graphql (1.9.15) lib/graphql/static_validation/rules/fragments_are_finite.rb:6:in `on_document'
  graphql (1.9.15) lib/graphql/static_validation/rules/fragment_names_are_unique.rb:17:in `on_document'
  graphql (1.9.15) lib/graphql/static_validation/rules/operation_names_are_valid.rb:16:in `on_document'
  graphql (1.9.15) lib/graphql/static_validation/rules/no_definitions_are_present.rb:34:in `on_document'
  graphql (1.9.15) lib/graphql/language/visitor.rb:79:in `visit_node'
  graphql (1.9.15) lib/graphql/language/visitor.rb:174:in `on_node_with_modifications'
  graphql (1.9.15) lib/graphql/language/visitor.rb:68:in `visit'
  graphql (1.9.15) lib/graphql/static_validation/validator.rb:42:in `block in validate'
  graphql (1.9.15) lib/graphql/tracing.rb:62:in `block in trace'
  graphql (1.9.15) lib/graphql/tracing.rb:76:in `call_tracers'
  graphql (1.9.15) lib/graphql/tracing.rb:62:in `trace'
  graphql (1.9.15) lib/graphql/static_validation/validator.rb:25:in `validate'
  graphql (1.9.15) lib/graphql/query/validation_pipeline.rb:75:in `ensure_has_validated'
  graphql (1.9.15) lib/graphql/query/validation_pipeline.rb:47:in `internal_representation'
  graphql (1.9.15) lib/graphql/query.rb:232:in `irep_selection'
  graphql (1.9.15) lib/graphql/schema/member/instrumentation.rb:22:in `before_query'
  graphql (1.9.15) lib/graphql/execution/instrumentation.rb:58:in `block in call_hooks'
  graphql (1.9.15) lib/graphql/execution/instrumentation.rb:57:in `call_hooks'
  graphql (1.9.15) lib/graphql/execution/instrumentation.rb:44:in `each_query_call_hooks'
  graphql (1.9.15) lib/graphql/execution/instrumentation.rb:27:in `block in apply_instrumenters'
  graphql (1.9.15) lib/graphql/execution/instrumentation.rb:72:in `call_hooks'
  graphql (1.9.15) lib/graphql/execution/instrumentation.rb:26:in `apply_instrumenters'
  graphql (1.9.15) lib/graphql/execution/multiplex.rb:174:in `instrument_and_analyze'
  graphql (1.9.15) lib/graphql/execution/multiplex.rb:61:in `block in run_queries'
  graphql (1.9.15) lib/graphql/tracing.rb:62:in `block in trace'
  graphql (1.9.15) lib/graphql/tracing.rb:76:in `call_tracers'
  graphql (1.9.15) lib/graphql/tracing.rb:62:in `trace'
  graphql (1.9.15) lib/graphql/execution/multiplex.rb:59:in `run_queries'
  graphql (1.9.15) lib/graphql/execution/multiplex.rb:49:in `run_all'
  graphql (1.9.15) lib/graphql/schema.rb:392:in `block in multiplex'
  graphql (1.9.15) lib/graphql/schema.rb:1279:in `with_definition_error_check'
  graphql (1.9.15) lib/graphql/schema.rb:391:in `multiplex'
  graphql (1.9.15) lib/graphql/schema.rb:368:in `execute'
  app/controllers/api/v1/graphql_controller.rb:25:in `execute_dev'
  actionpack (5.0.7.2) lib/action_controller/metal/basic_implicit_render.rb:4:in `send_action'
  actionpack (5.0.7.2) lib/abstract_controller/base.rb:188:in `process_action'
  actionpack (5.0.7.2) lib/action_controller/metal/rendering.rb:30:in `process_action'
  actionpack (5.0.7.2) lib/abstract_controller/callbacks.rb:20:in `block in process_action'
  activesupport (5.0.7.2) lib/active_support/callbacks.rb:126:in `call'
  activesupport (5.0.7.2) lib/active_support/callbacks.rb:506:in `block (2 levels) in compile'
  activesupport (5.0.7.2) lib/active_support/callbacks.rb:455:in `call'
  activesupport (5.0.7.2) lib/active_support/callbacks.rb:101:in `__run_callbacks__'
  activesupport (5.0.7.2) lib/active_support/callbacks.rb:750:in `_run_process_action_callbacks'
  activesupport (5.0.7.2) lib/active_support/callbacks.rb:90:in `run_callbacks'
  actionpack (5.0.7.2) lib/abstract_controller/callbacks.rb:19:in `process_action'
  actionpack (5.0.7.2) lib/action_controller/metal/rescue.rb:20:in `process_action'
  actionpack (5.0.7.2) lib/action_controller/metal/instrumentation.rb:32:in `block in process_action'
  activesupport (5.0.7.2) lib/active_support/notifications.rb:164:in `block in instrument'
  activesupport (5.0.7.2) lib/active_support/notifications/instrumenter.rb:21:in `instrument'
  activesupport (5.0.7.2) lib/active_support/notifications.rb:164:in `instrument'
  actionpack (5.0.7.2) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
  actionpack (5.0.7.2) lib/action_controller/metal/params_wrapper.rb:248:in `process_action'
  activerecord (5.0.7.2) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
  actionpack (5.0.7.2) lib/abstract_controller/base.rb:126:in `process'
  actionview (5.0.7.2) lib/action_view/rendering.rb:30:in `process'
  actionpack (5.0.7.2) lib/action_controller/metal.rb:190:in `dispatch'
  actionpack (5.0.7.2) lib/action_controller/metal.rb:262:in `dispatch'
  actionpack (5.0.7.2) lib/action_dispatch/routing/route_set.rb:50:in `dispatch'
  actionpack (5.0.7.2) lib/action_dispatch/routing/route_set.rb:32:in `serve'
  actionpack (5.0.7.2) lib/action_dispatch/journey/router.rb:39:in `block in serve'
  actionpack (5.0.7.2) lib/action_dispatch/journey/router.rb:26:in `serve'
  actionpack (5.0.7.2) lib/action_dispatch/routing/route_set.rb:727:in `call'
  warden (1.2.8) lib/warden/manager.rb:36:in `block in call'
  warden (1.2.8) lib/warden/manager.rb:34:in `call'
  rack (2.0.7) lib/rack/etag.rb:25:in `call'
  rack (2.0.7) lib/rack/conditional_get.rb:38:in `call'
  rack (2.0.7) lib/rack/head.rb:12:in `call'
  rack (2.0.7) lib/rack/session/abstract/id.rb:232:in `context'
  rack (2.0.7) lib/rack/session/abstract/id.rb:226:in `call'
  actionpack (5.0.7.2) lib/action_dispatch/middleware/cookies.rb:613:in `call'
  activerecord (5.0.7.2) lib/active_record/migration.rb:553:in `call'
  actionpack (5.0.7.2) lib/action_dispatch/middleware/callbacks.rb:38:in `block in call'
  activesupport (5.0.7.2) lib/active_support/callbacks.rb:97:in `__run_callbacks__'
  activesupport (5.0.7.2) lib/active_support/callbacks.rb:750:in `_run_call_callbacks'
  activesupport (5.0.7.2) lib/active_support/callbacks.rb:90:in `run_callbacks'
  actionpack (5.0.7.2) lib/action_dispatch/middleware/callbacks.rb:36:in `call'
  actionpack (5.0.7.2) lib/action_dispatch/middleware/executor.rb:12:in `call'
  actionpack (5.0.7.2) lib/action_dispatch/middleware/remote_ip.rb:79:in `call'
  airbrake (9.4.0) lib/airbrake/rack/middleware.rb:32:in `call!'
  airbrake (9.4.0) lib/airbrake/rack/middleware.rb:21:in `call'
  better_errors (2.1.1) lib/better_errors/middleware.rb:84:in `protected_app_call'
  better_errors (2.1.1) lib/better_errors/middleware.rb:79:in `better_errors_call'
  better_errors (2.1.1) lib/better_errors/middleware.rb:57:in `call'
  actionpack (5.0.7.2) lib/action_dispatch/middleware/debug_exceptions.rb:49:in `call'
  web-console (3.5.1) lib/web_console/middleware.rb:135:in `call_app'
  web-console (3.5.1) lib/web_console/middleware.rb:28:in `block in call'
  web-console (3.5.1) lib/web_console/middleware.rb:18:in `call'
  actionpack (5.0.7.2) lib/action_dispatch/middleware/show_exceptions.rb:31:in `call'
  railties (5.0.7.2) lib/rails/rack/logger.rb:36:in `call_app'
  railties (5.0.7.2) lib/rails/rack/logger.rb:24:in `block in call'
  activesupport (5.0.7.2) lib/active_support/tagged_logging.rb:69:in `block in tagged'
  activesupport (5.0.7.2) lib/active_support/tagged_logging.rb:26:in `tagged'
  activesupport (5.0.7.2) lib/active_support/tagged_logging.rb:69:in `tagged'
  railties (5.0.7.2) lib/rails/rack/logger.rb:24:in `call'
  actionpack (5.0.7.2) lib/action_dispatch/middleware/request_id.rb:24:in `call'
  rack (2.0.7) lib/rack/method_override.rb:22:in `call'
  rack (2.0.7) lib/rack/runtime.rb:22:in `call'
  activesupport (5.0.7.2) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
  actionpack (5.0.7.2) lib/action_dispatch/middleware/executor.rb:12:in `call'
  actionpack (5.0.7.2) lib/action_dispatch/middleware/static.rb:136:in `call'
  rack (2.0.7) lib/rack/sendfile.rb:111:in `call'
  rack-cors (1.0.3) lib/rack/cors.rb:95:in `call'
  railties (5.0.7.2) lib/rails/engine.rb:522:in `call'
  puma (4.0.1) lib/puma/configuration.rb:228:in `call'
  puma (4.0.1) lib/puma/server.rb:657:in `handle_request'
  puma (4.0.1) lib/puma/server.rb:467:in `process_client'
  puma (4.0.1) lib/puma/server.rb:328:in `block in run'
  puma (4.0.1) lib/puma/thread_pool.rb:135:in `block in spawn_thread'

For now I think I'll have to add a dummy field, but it would be nice to be able not to specify a mutation or query field if not necessary.

Same error here. It happens when I comment out the query field or if query is not visible (using .visible? on query class.

Hi, sorry about the frustration here. It looks like the gem started correctly enforcing a couple of parts of the spec:

The query root operation type must be provided and must be an Object type.

(https://graphql.github.io/graphql-spec/June2018/#sec-Root-Operation-Types)

And

An Object type must define one or more fields.

(https://graphql.github.io/graphql-spec/June2018/#sec-Objects)

So, your schema will always need a query root with at least one field! I'm sorry that this is a "breaking fix" in some cases, but I think we should comply with the spec in order to ensure that Ruby schemas are compatible with other GraphQL tooling.

Was this page helpful?
0 / 5 - 0 ratings