Skip to content
Snippets Groups Projects
Commit 3048929d authored by Manish R Jain's avatar Manish R Jain
Browse files

Correctly parse argument first

parent 3a7ac375
No related branches found
No related tags found
No related merge requests found
......@@ -238,24 +238,19 @@ func godeep(l *lex.Lexer, gq *GraphQuery) error {
return nil
} else if item.Typ == itemLeftRound {
// absorb all these, we don't use them right now.
/*
for {
var key, val string
item = <-l.Items
if item.Typ == itemArgName {
key = item.Val
} else if item.Typ == itemRightRound {
break
} else {
return nil, fmt.Errorf("Expecting argument name. Got: %v", item)
args, err := parseArguments(l)
if err != nil {
return err
}
// We only use argument 'first' for now.
for _, p := range args {
if p.Key == "first" {
count, err := strconv.ParseInt(p.Val, 0, 32)
if err != nil {
return err
}
}
*/
for ti := range l.Items {
fmt.Println(ti.String())
if ti.Typ == itemRightRound || ti.Typ == lex.ItemEOF {
return nil
curp.First = int(count)
}
}
}
......
......@@ -101,9 +101,7 @@ func TestParseXid(t *testing.T) {
}
}
/*
func TestParseFirst(t *testing.T) {
// logrus.SetLevel(logrus.DebugLevel)
query := `
query {
user(_xid_: m.abcd) {
......@@ -121,14 +119,39 @@ func TestParseFirst(t *testing.T) {
t.Error("subgraph is nil")
return
}
if len(gq.Children) != 1 {
t.Errorf("Expected 1 children. Got: %v", len(gq.Children))
if len(gq.Children) != 2 {
t.Errorf("Expected 2 children. Got: %v", len(gq.Children))
}
if err := checkAttr(gq.Children[0], "type.object.name"); err != nil {
t.Error(err)
}
if gq.Children[0].First != 0 {
t.Errorf("Expected count 0. Got: %v", gq.Children[0].First)
}
if err := checkAttr(gq.Children[1], "friends"); err != nil {
t.Error(err)
}
if gq.Children[1].First != 10 {
t.Errorf("Expected count 10. Got: %v", gq.Children[1].First)
}
}
func TestParseFirst_error(t *testing.T) {
query := `
query {
user(_xid_: m.abcd) {
type.object.name
friends (first: ) {
}
}
}`
var err error
_, _, err = Parse(query)
t.Log(err)
if err == nil {
t.Error("Expected error")
}
}
*/
func TestParse_error2(t *testing.T) {
query := `
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment