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

Uppercase as first field letter

Open docelic opened this issue 6 years ago • 1 comments

It appears that even though GraphQL supports case-sensitivity, creating fields with first letter uppercase does not work here because it generates invalid function names:

  field :Dir do ... end

Results in:

Error in src/x.cr:32: expanding macro

    field :"Dir" do
    ^

in macro 'field' expanded macro: injection:1, line 1:

>  1.         field(:Dir, "", args, "")  do
   2.   ::MyTest::Dir.new
   3. end
   4.         

macro didn't expand to a valid program, it expanded to:

================================================================================
--------------------------------------------------------------------------------
   1.         
   2.         private def Dir_field(args, context)
   3.           
   4.               context.with_self(args) do
   5.                 ::MyTest::Dir.new
   6.               end
   7.           
   8.         end
   9.         
--------------------------------------------------------------------------------
Syntax error in expanded macro: field:2: unexpected token: (

        private def Dir_field(args, context)

Would a simple fix be to generate functions named field_NAME instead of NAME_field?

docelic avatar Jun 21 '19 21:06 docelic

this could work. pull requests are always welcome!

ziprandom avatar Jun 22 '19 18:06 ziprandom