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

Broken Node Interface in new interpreter runtime #2082

Closed
Kenneth-KT opened this issue Feb 1, 2019 · 3 comments · Fixed by #2089
Closed

Broken Node Interface in new interpreter runtime #2082

Kenneth-KT opened this issue Feb 1, 2019 · 3 comments · Fixed by #2089
Milestone

Comments

@Kenneth-KT
Copy link

Kenneth-KT commented Feb 1, 2019

New interpreter from release 1.9.0 (#1884) has broken the node interface.

Given node interface fields are included in schema and new interpreter is enabled:

  field :node, field: GraphQL::Relay::Node.field
  field :nodes, field: GraphQL::Relay::Node.plural_field

  use GraphQL::Execution::Interpreter

and object_from_id is implemented as a debugger call:

def self.object_from_id(id, query_ctx)
    byebug
end

When present with query below:

{
  nodes(ids: ["any string"]) {
    id
  }
}

It responds with error below:

{
  "error": {
    "message": "Failed to build return type for Query.nodes from nil: Unexpected type input:  (NilClass)",
    "backtrace": [
      "/gems/graphql-1.9.0.pre2/lib/graphql/schema/member/build_type.rb:80:in `parse_type'",
      "/gems/graphql-1.9.0.pre2/lib/graphql/schema/field.rb:393:in `type'",
      "/gems/graphql-1.9.0.pre2/lib/graphql/execution/interpreter/runtime.rb:141:in `block in evaluate_selections'",
      "/gems/graphql-1.9.0.pre2/lib/graphql/execution/interpreter/runtime.rb:115:in `each'",
      "/gems/graphql-1.9.0.pre2/lib/graphql/execution/interpreter/runtime.rb:115:in `evaluate_selections'",
      "/gems/graphql-1.9.0.pre2/lib/graphql/execution/interpreter/runtime.rb:53:in `run_eager'",
      "/gems/graphql-1.9.0.pre2/lib/graphql/execution/interpreter.rb:73:in `block in evaluate'",
      "/gems/graphql-1.9.0.pre2/lib/graphql/tracing.rb:57:in `block in trace'",
      "/gems/graphql-1.9.0.pre2/lib/graphql/tracing.rb:71:in `call_tracers'",
      "/gems/graphql-1.9.0.pre2/lib/graphql/tracing.rb:57:in `trace'",
      "/gems/graphql-1.9.0.pre2/lib/graphql/execution/interpreter.rb:72:in `evaluate'",
      "/gems/graphql-1.9.0.pre2/lib/graphql/execution/interpreter.rb:45:in `begin_query'",
      "/gems/graphql-1.9.0.pre2/lib/graphql/execution/multiplex.rb:112:in `begin_query'",
      "/gems/graphql-1.9.0.pre2/lib/graphql/execution/multiplex.rb:84:in `block in run_as_multiplex'",
      "/gems/graphql-1.9.0.pre2/lib/graphql/execution/multiplex.rb:83:in `map'",
      "/gems/graphql-1.9.0.pre2/lib/graphql/execution/multiplex.rb:83:in `run_as_multiplex'",
      "/gems/graphql-1.9.0.pre2/lib/graphql/execution/multiplex.rb:62:in `block (2 levels) in run_queries'",
      "/gems/graphql-1.9.0.pre2/lib/graphql/execution/multiplex.rb:182:in `block in instrument_and_analyze'",
      "/gems/graphql-1.9.0.pre2/lib/graphql/execution/instrumentation.rb:29:in `block (2 levels) in apply_instrumenters'",
      "/gems/graphql-1.9.0.pre2/lib/graphql/execution/instrumentation.rb:46:in `block (2 levels) in each_query_call_hooks'",
      "/gems/graphql-1.9.0.pre2/lib/graphql/execution/instrumentation.rb:41:in `each_query_call_hooks'",
      "/gems/graphql-1.9.0.pre2/lib/graphql/execution/instrumentation.rb:45:in `block in each_query_call_hooks'",
      "/gems/graphql-1.9.0.pre2/lib/graphql/execution/instrumentation.rb:72:in `call_hooks'",
      "/gems/graphql-1.9.0.pre2/lib/graphql/execution/instrumentation.rb:44:in `each_query_call_hooks'",
      "/gems/graphql-1.9.0.pre2/lib/graphql/execution/instrumentation.rb:27:in `block in apply_instrumenters'",
      "/gems/graphql-1.9.0.pre2/lib/graphql/execution/instrumentation.rb:72:in `call_hooks'",
      "/gems/graphql-1.9.0.pre2/lib/graphql/execution/instrumentation.rb:26:in `apply_instrumenters'",
      "/gems/graphql-1.9.0.pre2/lib/graphql/execution/multiplex.rb:174:in `instrument_and_analyze'",
      "/gems/graphql-1.9.0.pre2/lib/graphql/execution/multiplex.rb:61:in `block in run_queries'",
      "/gems/graphql-1.9.0.pre2/lib/graphql/tracing.rb:57:in `block in trace'",
      "/gems/graphql-1.9.0.pre2/lib/graphql/tracing.rb:71:in `call_tracers'",
      "/gems/graphql-1.9.0.pre2/lib/graphql/tracing.rb:57:in `trace'",
      "/gems/graphql-1.9.0.pre2/lib/graphql/execution/multiplex.rb:59:in `run_queries'",
      "/gems/graphql-1.9.0.pre2/lib/graphql/execution/multiplex.rb:49:in `run_all'",
      "/gems/graphql-1.9.0.pre2/lib/graphql/schema.rb:375:in `block in multiplex'",
      "/gems/graphql-1.9.0.pre2/lib/graphql/schema.rb:1197:in `with_definition_error_check'",
      "/gems/graphql-1.9.0.pre2/lib/graphql/schema.rb:374:in `multiplex'",
      "/gems/graphql-1.9.0.pre2/lib/graphql/schema.rb:351:in `execute'",
      "/app/app/controllers/graphql_controller.rb:15:in `execute'",
      ".... omitted"
    ]
  },
  "data": {}
}

And the byebug debugger call was never triggered.

Expect it to trigger debugger call without errors.

It is reproducible in RubyGem version 1.9.pre2 and 1.9.pre3 using ruby version 2.5.3.

After disabling new interpreter by removing use GraphQL::Execution::Interpreter, it successfully triggers the debugger call.

@Kenneth-KT Kenneth-KT changed the title Broken Node Interface in 1.9 pre-release version Broken Node Interface in new interpreter runtime Feb 1, 2019
@rmosolgo rmosolgo added this to the 1.9.0 milestone Feb 1, 2019
@rmosolgo
Copy link
Owner

rmosolgo commented Feb 1, 2019

Hey, thanks for reporting this!

There's a work-around listed here: https://github.com/rmosolgo/graphql-ruby/blob/master/guides/queries/interpreter.md#installation. Could you give it a try and see if it fixes this for you?

But maybe the library can be improved so that the suggested code change is not required. I will take another look before releasing.

@Kenneth-KT
Copy link
Author

Hey, thanks for reporting this!

There's a work-around listed here: https://github.com/rmosolgo/graphql-ruby/blob/master/guides/queries/interpreter.md#installation. Could you give it a try and see if it fixes this for you?

But maybe the library can be improved so that the suggested code change is not required. I will take another look before releasing.

Thanks, it does work after replacing

  field :node, field: GraphQL::Relay::Node.field
  field :nodes, field: GraphQL::Relay::Node.plural_field

with

  add_field GraphQL::Types::Relay::NodeField
  add_field GraphQL::Types::Relay::NodesField

@rmosolgo
Copy link
Owner

rmosolgo commented Feb 6, 2019

The previous config will be supported with a warning in the next version. Thanks for reporting this!

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 a pull request may close this issue.

2 participants