From c03f7d6576d8d58e0c2e17b0f9895df7398da6c7 Mon Sep 17 00:00:00 2001 From: Vikram Rangnekar Date: Sat, 20 Apr 2019 10:45:12 -0400 Subject: [PATCH] Fix issue with fuzzbuzz config --- docs/guide.md | 7 +++---- fuzz.yaml | 4 ++-- qcode/parse_test.go | 16 +++++++++++----- qcode/qcode.go | 2 +- 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/docs/guide.md b/docs/guide.md index d89a1f6..577eef0 100644 --- a/docs/guide.md +++ b/docs/guide.md @@ -242,18 +242,17 @@ query { ### Using variables -Variables and their values can be passed along side the GraphQL query. Using variables makes for better client side code as well as improved server side -caching. The build-in web ui also hass support for variables. Not having to manupilate your GraphQL query string to insert values into it makes for cleaner +Variables (`$product_id`) and their values (`"product_id": 5`) can be passed along side the GraphQL query. Using variables makes for better client side code as well as improved server side SQL query caching. The build-in web-ui also supports setting variables. Not having to manipulate your GraphQL query string to insert values into it makes for cleaner and better client side code. ```javascript -// define the request object keeping the query and the variables seperate +// Define the request object keeping the query and the variables seperate var req = { query: '{ product(id: $product_id) { name } }' , variables: { "product_id": 5 } } -// use the fetch api to make the query +// Use the fetch api to make the query fetch('http://localhost:8080/api/v1/graphql', { method: 'POST', headers: { 'Content-Type': 'application/json' }, diff --git a/fuzz.yaml b/fuzz.yaml index 1297620..3a18da6 100644 --- a/fuzz.yaml +++ b/fuzz.yaml @@ -4,8 +4,8 @@ targets: language: go version: "1.12" corpus: ./corpus - #memory_limit: 1000 # in megabytes - #timeout: 500 # in milliseconds + memory_limit: "100" # in megabytes + timeout: "500" # in milliseconds harness: function: FuzzerEntrypoint # package defines where to import FuzzerEntrypoint from diff --git a/qcode/parse_test.go b/qcode/parse_test.go index ea93c57..b6545b0 100644 --- a/qcode/parse_test.go +++ b/qcode/parse_test.go @@ -45,9 +45,15 @@ func compareOp(op1, op2 Operation) error { return nil } -func TestParse(t *testing.T) { -} - -func BenchmarkParse(b *testing.B) { - +func TestCompile(t *testing.T) { + qcompile, _ := NewCompiler(Config{}) + _, err := qcompile.CompileQuery(`query { + product(id: 15) { + id + name + } + }`) + if err != nil { + t.Fatal(err) + } } diff --git a/qcode/qcode.go b/qcode/qcode.go index 3674a66..5955449 100644 --- a/qcode/qcode.go +++ b/qcode/qcode.go @@ -337,7 +337,7 @@ func (com *Compiler) compileQuery(op *Operation) (*Query, error) { } fil, ok := com.fm[selRoot.Table] - if !ok { + if !ok || fil == nil { fil = com.fl }