Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Named queries without variables support #4028

Merged
merged 2 commits into from
Sep 20, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions gql/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -1033,6 +1033,9 @@ func getSchema(it *lex.ItemIterator) (*pb.SchemaRequest, error) {
// parseGqlVariables parses the the graphQL variable declaration.
func parseGqlVariables(it *lex.ItemIterator, vmap varMap) error {
expectArg := true
if item, ok := it.PeekOne(); ok && item.Typ == itemRightRound {
return nil
}
for it.Next() {
var varName string
// Get variable name.
Expand Down
12 changes: 12 additions & 0 deletions gql/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,18 @@ func TestParseCountValError(t *testing.T) {
require.Contains(t, err.Error(), "Count of a variable is not allowed")
}

func TestParseQueryNamedQuery(t *testing.T) {
query := `
query works() {
q(func: has(name)) {
name
}
}
`
_, err := Parse(Request{Str: query})
require.NoError(t, err)
}

func TestParseVarError(t *testing.T) {
query := `
{
Expand Down