-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(request-payload-validation): Add test case reproducing bug report (
#11) Fixes #10 . * Adds a test case validating the bug report * Removed graphql-go in favor of gqlparser, which is more active and recent * Add SchemaProvider which loads and exposes the Schema for validations * Refactor code for gqlparser * Update test cases Decided to give awareness of the schema to go-graphql-armor, so it can validate and interpret with its knowledge. --------- Co-authored-by: ldebruijn <[email protected]>
- Loading branch information
Showing
12 changed files
with
462 additions
and
244 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package main | ||
|
||
import ( | ||
"github.com/stretchr/testify/require" | ||
"github.com/vektah/gqlparser/v2" | ||
"github.com/vektah/gqlparser/v2/ast" | ||
"github.com/vektah/gqlparser/v2/parser" | ||
"github.com/vektah/gqlparser/v2/validator" | ||
"testing" | ||
) | ||
|
||
func TestTest(t *testing.T) { | ||
s := gqlparser.MustLoadSchema( | ||
&ast.Source{Name: "graph/schema.graphqls", Input: ` | ||
extend type User { | ||
id: ID! | ||
} | ||
extend type Product { | ||
upc: String! | ||
} | ||
union _Entity = Product | User | ||
extend type Query { | ||
entity: _Entity | ||
} | ||
`, BuiltIn: false}, | ||
) | ||
|
||
q, err := parser.ParseQuery(&ast.Source{Name: "ff", Input: `{ | ||
entity { | ||
... on User { | ||
id | ||
} | ||
} | ||
}`}) | ||
require.Nil(t, err) | ||
require.Nil(t, validator.Validate(s, q)) | ||
} |
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.