Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
dgraph
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mirror
dgraph
Commits
3048929d
Commit
3048929d
authored
8 years ago
by
Manish R Jain
Browse files
Options
Downloads
Patches
Plain Diff
Correctly parse argument first
parent
3a7ac375
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
gql/parser.go
+12
-17
12 additions, 17 deletions
gql/parser.go
gql/parser_test.go
+28
-5
28 additions, 5 deletions
gql/parser_test.go
with
40 additions
and
22 deletions
gql/parser.go
+
12
−
17
View file @
3048929d
...
...
@@ -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
)
}
}
}
...
...
This diff is collapsed.
Click to expand it.
gql/parser_test.go
+
28
−
5
View file @
3048929d
...
...
@@ -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
:=
`
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment