Skip to content

Uppercase as first field letter #28

@docelic

Description

@docelic

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions