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

add validation for directive arguments inside Type Definition #4

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion ast/definition.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const (
// ObjectDefinition is the core type definition object, it includes all of the definable types
// but does *not* cover schema or directives.
//
// @vektah: Javascript implementation has different types for all of these, but they are
// @dgraph-io: Javascript implementation has different types for all of these, but they are
// more similar than different and don't define any behaviour. I think this style of
// "some hot" struct works better, at least for go.
//
Expand Down
4 changes: 2 additions & 2 deletions ast/document_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

. "github.com/vektah/gqlparser/ast"
"github.com/vektah/gqlparser/parser"
. "github.com/dgraph-io/gqlparser/ast"
"github.com/dgraph-io/gqlparser/parser"
)

func TestQueryDocMethods(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions formatter/formatter.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"sort"
"strings"

"github.com/vektah/gqlparser/ast"
"github.com/dgraph-io/gqlparser/ast"
)

type Formatter interface {
Expand Down Expand Up @@ -523,7 +523,7 @@ func (f *formatter) FormatVariableDefinition(def *ast.VariableDefinition) {
f.FormatValue(def.DefaultValue)
}

// TODO https://github.com/vektah/gqlparser/issues/102
// TODO https://github.com/dgraph-io/gqlparser/issues/102
// VariableDefinition : Variable : Type DefaultValue? Directives[Const]?
}

Expand Down
8 changes: 4 additions & 4 deletions formatter/formatter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import (
"unicode/utf8"

"github.com/stretchr/testify/assert"
"github.com/vektah/gqlparser"
"github.com/vektah/gqlparser/ast"
"github.com/vektah/gqlparser/formatter"
"github.com/vektah/gqlparser/parser"
"github.com/dgraph-io/gqlparser"
"github.com/dgraph-io/gqlparser/ast"
"github.com/dgraph-io/gqlparser/formatter"
"github.com/dgraph-io/gqlparser/parser"
)

var update = flag.Bool("u", false, "update golden files")
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/vektah/gqlparser
module github.com/dgraph-io/gqlparser

go 1.12

Expand Down
2 changes: 1 addition & 1 deletion gqlerror/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"
"strconv"

"github.com/vektah/gqlparser/ast"
"github.com/dgraph-io/gqlparser/ast"
)

// Error is the standard graphql error type described in https://facebook.github.io/graphql/draft/#sec-Errors
Expand Down
14 changes: 9 additions & 5 deletions gqlparser.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package gqlparser

import (
"github.com/vektah/gqlparser/ast"
"github.com/vektah/gqlparser/gqlerror"
"github.com/vektah/gqlparser/parser"
"github.com/vektah/gqlparser/validator"
_ "github.com/vektah/gqlparser/validator/rules"
"github.com/dgraph-io/gqlparser/ast"
"github.com/dgraph-io/gqlparser/gqlerror"
"github.com/dgraph-io/gqlparser/parser"
"github.com/dgraph-io/gqlparser/validator"
_ "github.com/dgraph-io/gqlparser/validator/rules"
)

func LoadSchema(str ...*ast.Source) (*ast.Schema, *gqlerror.Error) {
Expand Down Expand Up @@ -40,3 +40,7 @@ func MustLoadQuery(schema *ast.Schema, str string) *ast.QueryDocument {
}
return q
}

func LoadVariables(schema *ast.Schema, op *ast.OperationDefinition, vars map[string]interface{}) (map[string]*ast.Value, *gqlerror.Error) {
return validator.Variables(schema, op, vars)
}
4 changes: 2 additions & 2 deletions lexer/lexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"bytes"
"unicode/utf8"

"github.com/vektah/gqlparser/ast"
"github.com/vektah/gqlparser/gqlerror"
"github.com/dgraph-io/gqlparser/ast"
"github.com/dgraph-io/gqlparser/gqlerror"
)

// Lexer turns graphql request and schema strings into tokens
Expand Down
4 changes: 2 additions & 2 deletions lexer/lexer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package lexer
import (
"testing"

"github.com/vektah/gqlparser/ast"
"github.com/vektah/gqlparser/parser/testrunner"
"github.com/dgraph-io/gqlparser/ast"
"github.com/dgraph-io/gqlparser/parser/testrunner"
)

func TestLexer(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion lexer/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package lexer
import (
"strconv"

"github.com/vektah/gqlparser/ast"
"github.com/dgraph-io/gqlparser/ast"
)

const (
Expand Down
6 changes: 3 additions & 3 deletions parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package parser
import (
"strconv"

"github.com/vektah/gqlparser/ast"
"github.com/vektah/gqlparser/gqlerror"
"github.com/vektah/gqlparser/lexer"
"github.com/dgraph-io/gqlparser/ast"
"github.com/dgraph-io/gqlparser/gqlerror"
"github.com/dgraph-io/gqlparser/lexer"
)

type parser struct {
Expand Down
4 changes: 2 additions & 2 deletions parser/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"testing"

"github.com/stretchr/testify/require"
"github.com/vektah/gqlparser/ast"
"github.com/vektah/gqlparser/lexer"
"github.com/dgraph-io/gqlparser/ast"
"github.com/dgraph-io/gqlparser/lexer"
)

func TestParserUtils(t *testing.T) {
Expand Down
6 changes: 3 additions & 3 deletions parser/query.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package parser

import (
"github.com/vektah/gqlparser/gqlerror"
"github.com/vektah/gqlparser/lexer"
"github.com/dgraph-io/gqlparser/gqlerror"
"github.com/dgraph-io/gqlparser/lexer"

. "github.com/vektah/gqlparser/ast"
. "github.com/dgraph-io/gqlparser/ast"
)

func ParseQuery(source *Source) (*QueryDocument, *gqlerror.Error) {
Expand Down
4 changes: 2 additions & 2 deletions parser/query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package parser
import (
"testing"

"github.com/vektah/gqlparser/ast"
"github.com/vektah/gqlparser/parser/testrunner"
"github.com/dgraph-io/gqlparser/ast"
"github.com/dgraph-io/gqlparser/parser/testrunner"
)

func TestQueryDocument(t *testing.T) {
Expand Down
6 changes: 3 additions & 3 deletions parser/schema.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package parser

import (
. "github.com/vektah/gqlparser/ast"
"github.com/vektah/gqlparser/gqlerror"
"github.com/vektah/gqlparser/lexer"
. "github.com/dgraph-io/gqlparser/ast"
"github.com/dgraph-io/gqlparser/gqlerror"
"github.com/dgraph-io/gqlparser/lexer"
)

func ParseSchema(source *Source) (*SchemaDocument, *gqlerror.Error) {
Expand Down
4 changes: 2 additions & 2 deletions parser/schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package parser
import (
"testing"

"github.com/vektah/gqlparser/ast"
"github.com/vektah/gqlparser/parser/testrunner"
"github.com/dgraph-io/gqlparser/ast"
"github.com/dgraph-io/gqlparser/parser/testrunner"
)

func TestSchemaDocument(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion parser/testrunner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"testing"

"github.com/andreyvit/diff"
"github.com/vektah/gqlparser/gqlerror"
"github.com/dgraph-io/gqlparser/gqlerror"
"gopkg.in/yaml.v2"
)

Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
gqlparser [![CircleCI](https://badgen.net/circleci/github/vektah/gqlparser/master)](https://circleci.com/gh/vektah/gqlparser) [![Go Report Card](https://goreportcard.com/badge/github.com/vektah/gqlparser)](https://goreportcard.com/report/github.com/vektah/gqlparser) [![Coverage Status](https://badgen.net/coveralls/c/github/vektah/gqlparser)](https://coveralls.io/github/vektah/gqlparser?branch=master)
gqlparser [![CircleCI](https://badgen.net/circleci/github/dgraph-io/gqlparser/master)](https://circleci.com/gh/dgraph-io/gqlparser) [![Go Report Card](https://goreportcard.com/badge/github.com/dgraph-io/gqlparser)](https://goreportcard.com/report/github.com/dgraph-io/gqlparser) [![Coverage Status](https://badgen.net/coveralls/c/github/dgraph-io/gqlparser)](https://coveralls.io/github/dgraph-io/gqlparser?branch=master)
===

This is a parser for graphql, written to mirror the graphql-js reference implementation as closely while remaining idiomatic and easy to use.
Expand Down
4 changes: 2 additions & 2 deletions validator/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package validator
import (
"fmt"

"github.com/vektah/gqlparser/ast"
"github.com/vektah/gqlparser/gqlerror"
"github.com/dgraph-io/gqlparser/ast"
"github.com/dgraph-io/gqlparser/gqlerror"
)

type ErrorOption func(err *gqlerror.Error)
Expand Down
6 changes: 3 additions & 3 deletions validator/imported_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import (
"testing"

"github.com/stretchr/testify/require"
"github.com/vektah/gqlparser"
"github.com/vektah/gqlparser/ast"
"github.com/vektah/gqlparser/gqlerror"
"github.com/dgraph-io/gqlparser"
"github.com/dgraph-io/gqlparser/ast"
"github.com/dgraph-io/gqlparser/gqlerror"
"gopkg.in/yaml.v2"
)

Expand Down
2 changes: 1 addition & 1 deletion validator/prelude.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package validator

import "github.com/vektah/gqlparser/ast"
import "github.com/dgraph-io/gqlparser/ast"

var Prelude = &ast.Source{
Name: "prelude.graphql",
Expand Down
4 changes: 2 additions & 2 deletions validator/rules/fields_on_correct_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"fmt"
"sort"

"github.com/vektah/gqlparser/ast"
. "github.com/vektah/gqlparser/validator"
"github.com/dgraph-io/gqlparser/ast"
. "github.com/dgraph-io/gqlparser/validator"
)

func init() {
Expand Down
4 changes: 2 additions & 2 deletions validator/rules/fragments_on_composite_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package validator
import (
"fmt"

"github.com/vektah/gqlparser/ast"
. "github.com/vektah/gqlparser/validator"
"github.com/dgraph-io/gqlparser/ast"
. "github.com/dgraph-io/gqlparser/validator"
)

func init() {
Expand Down
4 changes: 2 additions & 2 deletions validator/rules/known_argument_names.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package validator

import (
"github.com/vektah/gqlparser/ast"
. "github.com/vektah/gqlparser/validator"
"github.com/dgraph-io/gqlparser/ast"
. "github.com/dgraph-io/gqlparser/validator"
)

func init() {
Expand Down
4 changes: 2 additions & 2 deletions validator/rules/known_directives.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package validator

import (
"github.com/vektah/gqlparser/ast"
. "github.com/vektah/gqlparser/validator"
"github.com/dgraph-io/gqlparser/ast"
. "github.com/dgraph-io/gqlparser/validator"
)

func init() {
Expand Down
4 changes: 2 additions & 2 deletions validator/rules/known_fragment_names.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package validator

import (
"github.com/vektah/gqlparser/ast"
. "github.com/vektah/gqlparser/validator"
"github.com/dgraph-io/gqlparser/ast"
. "github.com/dgraph-io/gqlparser/validator"
)

func init() {
Expand Down
4 changes: 2 additions & 2 deletions validator/rules/known_type_names.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package validator

import (
"github.com/vektah/gqlparser/ast"
. "github.com/vektah/gqlparser/validator"
"github.com/dgraph-io/gqlparser/ast"
. "github.com/dgraph-io/gqlparser/validator"
)

func init() {
Expand Down
4 changes: 2 additions & 2 deletions validator/rules/lone_anonymous_operation.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package validator

import (
"github.com/vektah/gqlparser/ast"
. "github.com/vektah/gqlparser/validator"
"github.com/dgraph-io/gqlparser/ast"
. "github.com/dgraph-io/gqlparser/validator"
)

func init() {
Expand Down
4 changes: 2 additions & 2 deletions validator/rules/no_fragment_cycles.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"fmt"
"strings"

"github.com/vektah/gqlparser/ast"
. "github.com/vektah/gqlparser/validator"
"github.com/dgraph-io/gqlparser/ast"
. "github.com/dgraph-io/gqlparser/validator"
)

func init() {
Expand Down
4 changes: 2 additions & 2 deletions validator/rules/no_undefined_variables.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package validator

import (
"github.com/vektah/gqlparser/ast"
. "github.com/vektah/gqlparser/validator"
"github.com/dgraph-io/gqlparser/ast"
. "github.com/dgraph-io/gqlparser/validator"
)

func init() {
Expand Down
4 changes: 2 additions & 2 deletions validator/rules/no_unused_fragments.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package validator

import (
"github.com/vektah/gqlparser/ast"
. "github.com/vektah/gqlparser/validator"
"github.com/dgraph-io/gqlparser/ast"
. "github.com/dgraph-io/gqlparser/validator"
)

func init() {
Expand Down
4 changes: 2 additions & 2 deletions validator/rules/no_unused_variables.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package validator

import (
"github.com/vektah/gqlparser/ast"
. "github.com/vektah/gqlparser/validator"
"github.com/dgraph-io/gqlparser/ast"
. "github.com/dgraph-io/gqlparser/validator"
)

func init() {
Expand Down
4 changes: 2 additions & 2 deletions validator/rules/overlapping_fields_can_be_merged.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"fmt"
"reflect"

"github.com/vektah/gqlparser/ast"
. "github.com/vektah/gqlparser/validator"
"github.com/dgraph-io/gqlparser/ast"
. "github.com/dgraph-io/gqlparser/validator"
)

func init() {
Expand Down
4 changes: 2 additions & 2 deletions validator/rules/possible_fragment_spreads.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package validator

import (
"github.com/vektah/gqlparser/ast"
. "github.com/vektah/gqlparser/validator"
"github.com/dgraph-io/gqlparser/ast"
. "github.com/dgraph-io/gqlparser/validator"
)

func init() {
Expand Down
4 changes: 2 additions & 2 deletions validator/rules/provided_required_arguments.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package validator

import (
"github.com/vektah/gqlparser/ast"
. "github.com/vektah/gqlparser/validator"
"github.com/dgraph-io/gqlparser/ast"
. "github.com/dgraph-io/gqlparser/validator"
)

func init() {
Expand Down
Loading