Skip to content

Commit

Permalink
parse arguments correctly for directive and list
Browse files Browse the repository at this point in the history
  • Loading branch information
mununki committed Aug 4, 2023
1 parent 952f9f7 commit 10a8438
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion command/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func (c *Command) Check() error {
NotEnoughArgs: "❌ Not enough arguments",
OutputFileNeeded: "❌ Output file argument is needed",
WrongOption: "❌ Wrong options",
Version: "v0.2.7",
Version: "v0.2.8",
}

help := flag.Bool("h", false, "show the help")
Expand Down
7 changes: 7 additions & 0 deletions lib/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -860,6 +860,10 @@ func ParseDirectives(l *Lexer) []*Directive {
}

d.DirectiveArgs = append(d.DirectiveArgs, &da)

if l.Peek() == ',' {
l.ConsumeToken(',')
}
}
l.ConsumeToken(')')
}
Expand All @@ -876,6 +880,9 @@ func ParseList(l *Lexer) []string {
} else {
ss = append(ss, l.ConsumeIdent())
}
if l.Peek() == ',' {
l.ConsumeToken(',')
}
}
return ss
}
5 changes: 2 additions & 3 deletions test/Directives.graphql
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
directive @goModel(
model: String
models: [String!]
model: String, models: [String!]
) on OBJECT | INPUT_OBJECT | SCALAR | ENUM | INTERFACE | UNION

"""
TEST
"""
interface Node @goModel(model: "todo/ent.Noder") {
interface Node @goModel(model: "todo/ent.Noder", models: ["a", "b"]) {
id: ID! # TEST
}

Expand Down

0 comments on commit 10a8438

Please sign in to comment.