0

I'm trying to define GraphQL type definitions. As far as I understand a class has to have a type definition named like the class, plus an appended Type. I have a class called CourseType, which leads me to this type definition:

app/graphql/types/course_type_type.rb

module Types
  class CourseTypeType < Types::BaseObject
    field :id, ID, null: false
    field :title, String, null: true
  end
end

When I try to open the GraphiQL site, I see the following error in the rails console:

Unhandled to_type_name input: {:Types=>Types::CourseTypeType} (Hash)

I assume that the problem occurs because of the class name, ending with Type, as I have another class Course, with a type definition named CourseType, which works fine.

I didn't find any similar error or documentation on this on Google. How do I have to write this correctly? Thank you.

Linus
  • 4,643
  • 8
  • 49
  • 74
  • I had a similar database model but never faced the issue you are referring to here. Can you mention the GraphQL-ruby version you are using? – Abhay Nikam Mar 08 '20 at 13:18
  • Yes @AbhayNikam it's version 1.10.3. – Linus Mar 11 '20 at 08:27
  • I'm actually able to get this to run just fine (created a file named course_type_type.rb with that class definition, and added a field to QueryType to retrieve it). Do you have a field in your QueryType for accessing it? – TonyArra Mar 18 '20 at 21:52

0 Answers0