-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
go 1.12 compat, planner fix, websocket fix (#236)
* Add datasource hooks (#67) * add hooks for graphql datasource * add graphql hooks to the contract * add hooks for http json data source * add hook test for http json * fix tests * fix extracting variables with multiple queries on contract (#71) * implement root field depths (TT-204) (#72) * provide per root field complexity * change internal complexity return values * wip: per field complexity * implement per root field complexity * fix linter errors * change namings according some PR remarks * Fix/tt 571 update field depth calculation (#73) * rename operation_complexity.FieldComplexityResult to RootFieldStats fix depth calculation for the root fields * remove unnecessary allocations * reset counters after living root field (#75) * Feat/add introspectionhelper to graphql (#74) * add node modules to gitignore * add IsIntrospectionQuery to graphql.Request * add IntrospectionResponse to graphql.Schema * add detecting introspection query without name * add more safe conditions Co-authored-by: Sergey Petrunin <sergey@tyk.io> * fix detecting introspection (#76) add data root field to introspection response * add helper introspection as an execution result (#77) * implement missing subscription and websocket protocol parts (TT-904) (#78) * send complete on unsubscribe * update tests and function returns * add ability to execute non-subscription query * add test for server returning error on invalid queries * add buffer pool * expose some websocket functionality * fix potential issues with websocket handler * go fmt & imports * fix build * fix websocket client cleanup websocket client test * add tests for operation selection * fix operation name selection * add error cases * add compatibility for go 1.12 * use WithContext correct * refactor OperationNameExists function * iterate root nodes instead of operation definition as it could lead to bugs * select number of operations in document from rootnodes * update deps Co-authored-by: Patric Vormstein <pvormstein@googlemail.com> Co-authored-by: Sergey Petrunin <spetrunin@users.noreply.github.com> Co-authored-by: Sergey Petrunin <sergey@tyk.io>
- Loading branch information
1 parent
d95768c
commit 9089130
Showing
73 changed files
with
2,061 additions
and
278 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package ast | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestDocument_OperationNameExists(t *testing.T) { | ||
run := func(operationDefinitionsFunc func(doc *Document) []OperationDefinition, operationName string, expectedExists bool) func(t *testing.T) { | ||
return func(t *testing.T) { | ||
doc := Document{} | ||
operationDefinitions := operationDefinitionsFunc(&doc) | ||
doc.OperationDefinitions = append(doc.OperationDefinitions, operationDefinitions...) | ||
for i := range doc.OperationDefinitions { | ||
doc.RootNodes = append(doc.RootNodes, Node{ | ||
Kind: NodeKindOperationDefinition, | ||
Ref: i, | ||
}) | ||
} | ||
exists := doc.OperationNameExists(operationName) | ||
assert.Equal(t, expectedExists, exists) | ||
} | ||
} | ||
|
||
t.Run("not found on empty document", run( | ||
func(doc *Document) []OperationDefinition { | ||
return []OperationDefinition{} | ||
}, | ||
"MyOperation", | ||
false, | ||
)) | ||
|
||
t.Run("not found on document with multiple operations", run( | ||
func(doc *Document) []OperationDefinition { | ||
return []OperationDefinition{ | ||
{ | ||
Name: doc.Input.AppendInputString("OtherOperation"), | ||
}, | ||
{ | ||
Name: doc.Input.AppendInputString("AnotherOperation"), | ||
}, | ||
} | ||
}, | ||
"MyOperation", | ||
false, | ||
)) | ||
|
||
t.Run("found on document with a single operations", run( | ||
func(doc *Document) []OperationDefinition { | ||
return []OperationDefinition{ | ||
{ | ||
Name: doc.Input.AppendInputString("MyOperation"), | ||
}, | ||
} | ||
}, | ||
"MyOperation", | ||
true, | ||
)) | ||
|
||
t.Run("found on document with multiple operations", run( | ||
func(doc *Document) []OperationDefinition { | ||
return []OperationDefinition{ | ||
{ | ||
Name: doc.Input.AppendInputString("OtherOperation"), | ||
}, | ||
{ | ||
Name: doc.Input.AppendInputString("MyOperation"), | ||
}, | ||
{ | ||
Name: doc.Input.AppendInputString("AnotherOperation"), | ||
}, | ||
} | ||
}, | ||
"MyOperation", | ||
true, | ||
)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.