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

Error with Hello World schema #6

Open
kefahi opened this issue Oct 23, 2019 · 2 comments · May be fixed by #7
Open

Error with Hello World schema #6

kefahi opened this issue Oct 23, 2019 · 2 comments · May be fixed by #7

Comments

@kefahi
Copy link

kefahi commented Oct 23, 2019

When enabling hello_world_schema the following compiler error is thrown:

query "hello" { "world" }
      ^----
Error: undefined method 'query' for GraphQL::Schema::Schema (with ... yield) and Kemal::GraphQL:Module (current scope)

The way how that hello world example is written is very nice and good for simple cases. But it seems some maintenance is needed there.

@kefahi
Copy link
Author

kefahi commented Oct 23, 2019

I figured it out, this was the "old" style that seems to be deprecated now. (I like the simpler old style btw :) )

The change I had to do to the Hello world example to work is the following

require "graphql-crystal"

module Kemal::GraphQL
  module RootQuery
    include ::GraphQL::ObjectType
    extend self
    field "hello" { "world" }
  end

  HELLO_WORLD_SCHEMA = ::GraphQL::Schema.from_schema(
    %{
      schema {
        query: RootQuery
      }

      type RootQuery {
        hello: String
      }
    }
  )
  HELLO_WORLD_SCHEMA.query_resolver = RootQuery
end

@ziprandom
Copy link
Owner

ziprandom commented Oct 24, 2019 via email

@kefahi kefahi linked a pull request Oct 24, 2019 that will close this issue
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