This repository has been archived by the owner on Nov 8, 2017. It is now read-only.
forked from graphql-go/graphql
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move types and their dependencies to graphql
- Loading branch information
Showing
74 changed files
with
5,115 additions
and
5,275 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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,33 @@ | ||
package graphql | ||
|
||
import ( | ||
"github.com/chris-ramon/graphql/kinds" | ||
) | ||
|
||
// Argument implements Node | ||
type AstArgument struct { | ||
Kind string | ||
Loc *AstLocation | ||
Name *AstName | ||
Value Value | ||
} | ||
|
||
func NewAstArgument(arg *AstArgument) *AstArgument { | ||
if arg == nil { | ||
arg = &AstArgument{} | ||
} | ||
return &AstArgument{ | ||
Kind: kinds.Argument, | ||
Loc: arg.Loc, | ||
Name: arg.Name, | ||
Value: arg.Value, | ||
} | ||
} | ||
|
||
func (arg *AstArgument) GetKind() string { | ||
return arg.Kind | ||
} | ||
|
||
func (arg *AstArgument) GetLoc() *AstLocation { | ||
return arg.Loc | ||
} |
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,153 @@ | ||
package graphql | ||
|
||
import ( | ||
"github.com/chris-ramon/graphql/kinds" | ||
) | ||
|
||
type Definition interface { | ||
// TODO: determine the minimal set of interface for `Definition` | ||
GetOperation() string | ||
GetVariableDefinitions() []*AstVariableDefinition | ||
GetSelectionSet() *AstSelectionSet | ||
} | ||
|
||
// Ensure that all definition types implements Definition interface | ||
var _ Definition = (*AstOperationDefinition)(nil) | ||
var _ Definition = (*AstFragmentDefinition)(nil) | ||
var _ Definition = (Definition)(nil) | ||
|
||
// AstOperationDefinition implements Node, Definition | ||
type AstOperationDefinition struct { | ||
Kind string | ||
Loc *AstLocation | ||
Operation string | ||
Name *AstName | ||
VariableDefinitions []*AstVariableDefinition | ||
Directives []*AstDirective | ||
SelectionSet *AstSelectionSet | ||
} | ||
|
||
func NewAstOperationDefinition(op *AstOperationDefinition) *AstOperationDefinition { | ||
if op == nil { | ||
op = &AstOperationDefinition{} | ||
} | ||
return &AstOperationDefinition{ | ||
Kind: kinds.OperationDefinition, | ||
Loc: op.Loc, | ||
Operation: op.Operation, | ||
Name: op.Name, | ||
VariableDefinitions: op.VariableDefinitions, | ||
Directives: op.Directives, | ||
SelectionSet: op.SelectionSet, | ||
} | ||
} | ||
|
||
func (op *AstOperationDefinition) GetKind() string { | ||
return op.Kind | ||
} | ||
|
||
func (op *AstOperationDefinition) GetLoc() *AstLocation { | ||
return op.Loc | ||
} | ||
|
||
func (op *AstOperationDefinition) GetOperation() string { | ||
return op.Operation | ||
} | ||
|
||
func (op *AstOperationDefinition) GetName() *AstName { | ||
return op.Name | ||
} | ||
|
||
func (op *AstOperationDefinition) GetVariableDefinitions() []*AstVariableDefinition { | ||
return op.VariableDefinitions | ||
} | ||
|
||
func (op *AstOperationDefinition) GetDirectives() []*AstDirective { | ||
return op.Directives | ||
} | ||
|
||
func (op *AstOperationDefinition) GetSelectionSet() *AstSelectionSet { | ||
return op.SelectionSet | ||
} | ||
|
||
// AstFragmentDefinition implements Node, Definition | ||
type AstFragmentDefinition struct { | ||
Kind string | ||
Loc *AstLocation | ||
Operation string | ||
Name *AstName | ||
VariableDefinitions []*AstVariableDefinition | ||
TypeCondition *AstNamed | ||
Directives []*AstDirective | ||
SelectionSet *AstSelectionSet | ||
} | ||
|
||
func NewAstFragmentDefinition(fd *AstFragmentDefinition) *AstFragmentDefinition { | ||
if fd == nil { | ||
fd = &AstFragmentDefinition{} | ||
} | ||
return &AstFragmentDefinition{ | ||
Kind: kinds.FragmentDefinition, | ||
Loc: fd.Loc, | ||
Operation: fd.Operation, | ||
Name: fd.Name, | ||
VariableDefinitions: fd.VariableDefinitions, | ||
TypeCondition: fd.TypeCondition, | ||
Directives: fd.Directives, | ||
SelectionSet: fd.SelectionSet, | ||
} | ||
} | ||
|
||
func (fd *AstFragmentDefinition) GetKind() string { | ||
return fd.Kind | ||
} | ||
|
||
func (fd *AstFragmentDefinition) GetLoc() *AstLocation { | ||
return fd.Loc | ||
} | ||
|
||
func (fd *AstFragmentDefinition) GetOperation() string { | ||
return fd.Operation | ||
} | ||
|
||
func (fd *AstFragmentDefinition) GetName() *AstName { | ||
return fd.Name | ||
} | ||
|
||
func (fd *AstFragmentDefinition) GetVariableDefinitions() []*AstVariableDefinition { | ||
return fd.VariableDefinitions | ||
} | ||
|
||
func (fd *AstFragmentDefinition) GetSelectionSet() *AstSelectionSet { | ||
return fd.SelectionSet | ||
} | ||
|
||
// AstVariableDefinition implements Node | ||
type AstVariableDefinition struct { | ||
Kind string | ||
Loc *AstLocation | ||
Variable *AstVariable | ||
Type AstType | ||
DefaultValue Value | ||
} | ||
|
||
func NewAstVariableDefinition(vd *AstVariableDefinition) *AstVariableDefinition { | ||
if vd == nil { | ||
vd = &AstVariableDefinition{} | ||
} | ||
return &AstVariableDefinition{ | ||
Kind: kinds.VariableDefinition, | ||
Loc: vd.Loc, | ||
Variable: vd.Variable, | ||
Type: vd.Type, | ||
DefaultValue: vd.DefaultValue, | ||
} | ||
} | ||
|
||
func (vd *AstVariableDefinition) GetKind() string { | ||
return vd.Kind | ||
} | ||
|
||
func (vd *AstVariableDefinition) GetLoc() *AstLocation { | ||
return vd.Loc | ||
} |
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,33 @@ | ||
package graphql | ||
|
||
import ( | ||
"github.com/chris-ramon/graphql/kinds" | ||
) | ||
|
||
// Directive implements Node | ||
type AstDirective struct { | ||
Kind string | ||
Loc *AstLocation | ||
Name *AstName | ||
Arguments []*AstArgument | ||
} | ||
|
||
func NewAstDirective(dir *AstDirective) *AstDirective { | ||
if dir == nil { | ||
dir = &AstDirective{} | ||
} | ||
return &AstDirective{ | ||
Kind: kinds.Directive, | ||
Loc: dir.Loc, | ||
Name: dir.Name, | ||
Arguments: dir.Arguments, | ||
} | ||
} | ||
|
||
func (dir *AstDirective) GetKind() string { | ||
return dir.Kind | ||
} | ||
|
||
func (dir *AstDirective) GetLoc() *AstLocation { | ||
return dir.Loc | ||
} |
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,31 @@ | ||
package graphql | ||
|
||
import ( | ||
"github.com/chris-ramon/graphql/kinds" | ||
) | ||
|
||
// Document implements Node | ||
type AstDocument struct { | ||
Kind string | ||
Loc *AstLocation | ||
Definitions []Node | ||
} | ||
|
||
func NewAstDocument(d *AstDocument) *AstDocument { | ||
if d == nil { | ||
d = &AstDocument{} | ||
} | ||
return &AstDocument{ | ||
Kind: kinds.Document, | ||
Loc: d.Loc, | ||
Definitions: d.Definitions, | ||
} | ||
} | ||
|
||
func (node *AstDocument) GetKind() string { | ||
return node.Kind | ||
} | ||
|
||
func (node *AstDocument) GetLoc() *AstLocation { | ||
return node.Loc | ||
} |
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,18 @@ | ||
package graphql | ||
|
||
type AstLocation struct { | ||
Start int | ||
End int | ||
Source *Source | ||
} | ||
|
||
func NewAstLocation(loc *AstLocation) *AstLocation { | ||
if loc == nil { | ||
loc = &AstLocation{} | ||
} | ||
return &AstLocation{ | ||
Start: loc.Start, | ||
End: loc.End, | ||
Source: loc.Source, | ||
} | ||
} |
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,31 @@ | ||
package graphql | ||
|
||
import ( | ||
"github.com/chris-ramon/graphql/kinds" | ||
) | ||
|
||
// AstName implements Node | ||
type AstName struct { | ||
Kind string | ||
Loc *AstLocation | ||
Value string | ||
} | ||
|
||
func NewAstName(node *AstName) *AstName { | ||
if node == nil { | ||
node = &AstName{} | ||
} | ||
return &AstName{ | ||
Kind: kinds.Name, | ||
Value: node.Value, | ||
Loc: node.Loc, | ||
} | ||
} | ||
|
||
func (node *AstName) GetKind() string { | ||
return node.Kind | ||
} | ||
|
||
func (node *AstName) GetLoc() *AstLocation { | ||
return node.Loc | ||
} |
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,45 @@ | ||
package graphql | ||
|
||
type Node interface { | ||
GetKind() string | ||
GetLoc() *AstLocation | ||
} | ||
|
||
// The list of all possible AST node graphql. | ||
// Ensure that all node types implements Node interface | ||
var _ Node = (*AstName)(nil) | ||
var _ Node = (*AstDocument)(nil) | ||
var _ Node = (*AstOperationDefinition)(nil) | ||
var _ Node = (*AstVariableDefinition)(nil) | ||
var _ Node = (*AstVariable)(nil) | ||
var _ Node = (*AstSelectionSet)(nil) | ||
var _ Node = (*AstField)(nil) | ||
var _ Node = (*AstArgument)(nil) | ||
var _ Node = (*AstFragmentSpread)(nil) | ||
var _ Node = (*AstInlineFragment)(nil) | ||
var _ Node = (*AstFragmentDefinition)(nil) | ||
var _ Node = (*AstIntValue)(nil) | ||
var _ Node = (*AstFloatValue)(nil) | ||
var _ Node = (*AstStringValue)(nil) | ||
var _ Node = (*AstBooleanValue)(nil) | ||
var _ Node = (*AstEnumValue)(nil) | ||
var _ Node = (*AstListValue)(nil) | ||
var _ Node = (*AstObjectValue)(nil) | ||
var _ Node = (*AstObjectField)(nil) | ||
var _ Node = (*AstDirective)(nil) | ||
var _ Node = (*AstList)(nil) | ||
var _ Node = (*AstNonNull)(nil) | ||
var _ Node = (*AstObjectDefinition)(nil) | ||
var _ Node = (*AstFieldDefinition)(nil) | ||
var _ Node = (*AstInputValueDefinition)(nil) | ||
var _ Node = (*AstInterfaceDefinition)(nil) | ||
var _ Node = (*AstUnionDefinition)(nil) | ||
var _ Node = (*AstScalarDefinition)(nil) | ||
var _ Node = (*AstEnumDefinition)(nil) | ||
var _ Node = (*AstEnumValueDefinition)(nil) | ||
var _ Node = (*AstInputObjectDefinition)(nil) | ||
var _ Node = (*AstTypeExtensionDefinition)(nil) | ||
|
||
// TODO: File issue in `graphql-js` where AstNamed is not | ||
// defined as a Node. This might be a mistake in `graphql-js`? | ||
var _ Node = (*AstNamed)(nil) |
Oops, something went wrong.