graphql-client icon indicating copy to clipboard operation
graphql-client copied to clipboard

Lowercase Query name throws error in Parser

Open eins78 opened this issue 6 years ago • 0 comments

See example below. It seems that the Name of a query must adhere to Ruby conventions to be used with this client, but the spec allows for more: https://graphql.github.io/graphql-spec/June2018/#Name

require 'graphql'
require 'graphql/client'

module Types
  class QueryType < GraphQL::Schema::Object
    field :one, Integer, null: false do
      1
    end
  end
end

class DummyGraphqlSchema < GraphQL::Schema
  query(Types::QueryType)
end

module DummyAPI
  Schema = GraphQL::Client.load_schema(DummyGraphqlSchema)
  Client = GraphQL::Client.new(schema: Schema)
end

# works
puts DummyAPI::Client.parse <<-'GRAPHQL'
  query { one }
GRAPHQL

# works
puts DummyAPI::Client.parse <<-'GRAPHQL'
  query TheOne { one }
GRAPHQL

# does not work but should <https://graphql.github.io/graphql-spec/June2018/#Name>
puts DummyAPI::Client.parse <<-'GRAPHQL'
  query theOne { one }
GRAPHQL

results in error:

/Users/ma/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/graphql-client-0.14.0/lib/graphql/client.rb:249:in `const_set': wrong constant name theOne (NameError)

eins78 avatar Jul 08 '19 08:07 eins78